Python: DictWriter overwrites rows when file reaches certain size -


i've encountered strange problem when using dictwriter add rows end of csv inside loop. when file reaches 12288 bytes, rows no longer added , replaced instead. check this, ran simple test:

import pandas pd import csv test=pd.dataframe(columns=('key1','key2','key3','key4','key5')) test.to_csv("testwrite.csv",index=false)  in range(500):      headers={}     data={}     words={'key1':'col1','key2':'col2','key3':'col3','key4':'col4','key5':'col5'}      k,v in words.items():         headers[k]='keyval'+str(i)         data[k]='colval'+str(i)      open("testwrite.csv", 'r+',newline='\n') f:         header=next(csv.reader(f))         dw=csv.dictwriter(f, header)         dw.writerow(data)         f.close() 

has encountered similar problem or have solution this?


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -