I have python 2.7 program used on a unix server that reads in an ASCII file with two types of information and processes that information. I have put this process into a function that essentially does:
def read_info()
f = open(file_name, 'rb')
f_enumerator = enumerate(f, start=1)
for i, line in f_enumerator:
process_info
process_last_info
When this function is called on the file from my main program, it stops at a seemingly arbitrary point halfway through a line towards the end of the input file, whereas when the function is called from a simple wrapper on the same input file it reads the entire file correctly.
I have tried one of the solutions here: Python Does Not Read Entire Text File , Where the file is read in as binary but that did not fix the problem. The other solution there (reading in the file in chunks) would be problematic as I am trying to parse the file on a line-specific basis, and reading in a chunks of text would require a lot more parsing.
I would be willing to do that, except that the intermittent nature of the problem suggests to me that there might be some other solution?