I am pulling data from a Rally server, and would like to write it to a CSV file and create snapshots. I am creating the file with:
orig_stdout = sys.stdout
timestr = time.strftime("%m-%d-%Y")
f = open(timestr+'FileName.csv', 'w')
sys.stdout = f
#all of the setup and functions
sys.stdout = orig_stdout
f.close()
The output I am writing to file comes from:
for item in response:
print("%s, %s, %s, %s" % (item.Attribute1, item.Attribute2, item.Attribute3, item.Attribute4))
The problem is that the strings will occasionally have a comma in it already. This is true for every usual character. I do not wish to replace the commas in said strings.
Is there a special character I can use that an Excel CSV file would recognize and be able to split into columns properly, or can I somehow tell the file to delimit using a multiple characters such as ",,"
csvmodule?with open('file.csv', 'w') as out: out.write('text')