Read a file in python starting with a particular string
<p>I have a file in the following path:</p>

<pre><code>/home/[user]/foo_01-01-2016.txt
</code></pre>

<p>I need to read it using the wild card (*) character:</p>

<pre><code>import pandas as pd
df = pd.read_csv("/home/[user]/foo_*.txt")
</code></pre>

<p>But its giving a file not found error.</p>

<p>You can use <a href="https://docs.python.org/3.5/library/glob.html" rel="nofollow"><code>glob</code></a>, but output is list, so select first item by <code>[0]</code>:</p>

<pre><code>import pandas as pd
import glob

path =r'/home/[user]'
filename = glob.glob(path + "/foo_*.txt")
print (filename[0])

df = pd.read_csv(filename[0])
print (df)
</code></pre>

python file pandas dataframe wildcard