I am attempting to write data (mostly dates, booleans and float data types) into a CSV file format. Here is a snippet of my code:
# Write data to file
with open(OUTPUT_DIR + output_filename,'w') as outputfile:
wrtr = csv.writer(outputfile, delimiter=',', quotechar='"')
for x, y in datarows.items():
a,b,c,d,e,f,g = (somedate.strft('%Y-%m-%d'),0,6058.7,False,1913736200,0,False)
rowstr = "{0},{1},{2},{3},{4},{5},{6}".format(a,b,c,d,e,f,g)
wrtr.writerow(rowstr)
outputfile.close()
File contents look like this:
2,0,0,7,-,10,-,03,",",0,",",6,0,5,8,.,7,",",F,a,l,s,e,",",1,9,1,3,7,3,6,2,0,0,",",0,",",F,a,l,s,e
I am currently using the raw file object to write to file - but I would prefer to use the csvwrite - since that is what its supposed to be used for
outputfilewhen you're usingwithstatement? what thisdatarowsfor loop is for?