Writing from a large list to a text file in Python -



Writing from a large list to a text file in Python -

something unusual happens when seek write ordinary list, containing 648470 string-values, text file.

textfile = open('bins.txt', 'w') item in biglist: print item # prints fine textfile.write(item) textfile.close()

the text file grows rapidly in file size , filled kind of symbols, not intended ones... if write little span of content of biglist text file gets corrupted. if exact same thing much smaller list, there's no problem. big size of list causing problem? output of print(biglist[:10]) is

['167', '14444', '118', '22110', '118', '8134', '82', '8949', '7875', '171']

it works absolutely fine me.

in code forgetting close file, , also, since open file in append mode, guess have garbage in file there , forgot remove.

also, maintain in mind write in way not separate numbers in way.

python

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -