Reputation: 125
I would like to open a file called "summary" and read information out of it to write into an output file, however I cannot open "summary"
I have tried to verify that the path exists - which works:
import os.path
print os.path.exists('/Users/alli/Documents/Summer2016/sfit4_trial/summary')
This prints out true. However when I try to do
import os
import glob
path = '/Users/alli/Documents/Summer2016/sfit4_trial/summary'
for infile in glob.glob(os.path.join(path, '*')):
file = open(infile, 'r').read()
print file
Nothing happens. I have looked through similar questions on SO and tried them all but not having any luck. All suggestions welcome. Thanks.
Upvotes: 0
Views: 2492
Reputation: 5783
Have you tried?
...
path = '/Users/alli/Documents/Summer2016/sfit4_trial'
for infile in glob.glob(os.path.join(path, 'summary*')):
...
Upvotes: 1