csv.write skipping lines when writing to csv

后端 未结 5 1464
旧巷少年郎
旧巷少年郎 2021-01-01 11:50

I am trying to write to a csv file via the following

file = open(\'P:\\test.csv\', \'a\') 

fieldnames = (\'ItemID\', \'Factor\', \'FixedAmount\')
wr = csv.D         


        
5条回答
  •  别那么骄傲
    2021-01-01 11:54

    Could it be that you are opening the output file in append mode?

    file = open('P:\test.csv', 'a') 
    #                           ^
    

    Instead of write mode? If you run the program several times, the output from every run will be in that file...

提交回复
热议问题