Something strange happens when I try to write from a ordinary list, containing 648470 string-values, to a text file.
textFile = open('bins.txt', 'w')
for item in bigList:
print item # This prints fine
textFile.write(item)
textFile.close()
The text file grows rapidly in file size and is filled with all kind of symbols, not the intended ones... Even if I just write a small span of the content of bigList the text file gets corrupted. If I do the exact same thing with a much smaller list, there's no problem.
Is the large size of the list causing this problem? The output of print(bigList[:10]) is
['167', '14444', '118', '22110', '118', '8134', '82', '8949', '7875', '171']
textFile = open(path, 'w')? And are you sure you are writing text, and not numbers into each line?print(bigList[:20]), for example.'a', not'w'. What was in the file before? And—not to be patronizing, but I've made this kind of mistake before—are you sure you're looking at the data you appended, rather than the garbage that was already there? In fact, are you sure you appended anything at all (since you don'tclosethe file, it may never flush the buffer to disk)?