I am trying to write my dictionary in a sf file, here is how i am doing it:
with open(path3 + 'extend.csv', 'w') as fw:
for key1, value in d.items():
fw.write(value +',')
fw.write('\n')
fw.close()
The thing is that I get an extra comma at the end of each line. How can I prevent this form happing in the first place?
dictitem order is not maintained. This approach is fine if you don't care what order you're putting those values into the csv file, but I think for most people they do care. Either iterate over specific dict keys or switch to a list ford(which maintains order).