I have many files made by a software. I want to extract some data from those files, and when I open the file with textedit, I see that what i need is on the first line. i have many of these files, and when I run the script, it works only for couple of them. Here I put the script I use, and example of a working and not working file. I spend hours on that, it would be great if you can have a look.
import glob path = "/Users/Desktop/files/" #you might need to modify ListFiles =glob.glob(path+'*') print ListFiles for i in ListFiles: print i handle = open(i,'r') text = handle.readlines() print text print text handle.close()
print text returns a list of lines for both files, but text only works for the second file.