I'm using idle in OS X, and I'm trying to parse a file with .data
extension:
FP = open('<filename>.data','r')
lines=FP.readlines()
print lines
but this prints an empty array: []
I also tried Sublime but also doesn't work. What is another method to use in Python to read this?
open it in binary mode and print the repr of its contents instead
print os.stat("filename.data") #ensure that st_size > 0
with open("filename.data","rb") as f:
print repr(f.read())
if this gives an empty string than you indeed have an empty file ...
im guessing ls -l tells you that the file is 0 bytes big?