alli
alli

Reputation: 125

opening a file without an extension python

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

Answers (1)

Szabolcs Dombi
Szabolcs Dombi

Reputation: 5783

Have you tried?

...
path = '/Users/alli/Documents/Summer2016/sfit4_trial'
for infile in glob.glob(os.path.join(path, 'summary*')):
    ...

Upvotes: 1

Related Questions