I am trying to write some values onto a CSV file but all the values are getting jammed into one column how do I use a different column for each value? Please go easy on me I am an absolute beginner with programming. It would be really helpful if someone could write an example code on how to solve this issue
Here is my code:
with open('log.csv', 'a',) as file:
fieldnames = ['Timestamp', 'Overall result', 'Soll-orderno', 'Desired-HW-Version', 'Desired-SF-Version',
'Desired-productcode', 'Desired-device-type', 'Scancode', 'Wbm-orderno', 'Wbm-HW-Version', 'Wbm-SF-Version',
'Wbm-mac-address', 'test-product-code', 'combined-product-code' , 'wbm-device-type', 'test-device-type']
writer = csv.DictWriter(file, fieldnames=fieldnames)
writer.writeheader()
writer.writerow({'Timestamp':now, 'Overall result':'Blank', 'Soll-orderno':d_ordernum, 'Desired-HW-Version':d_hw_version, 'Desired-SF-Version':d_sf_version,
'Desired-productcode':pc_praefix, 'Desired-device-type':d_dev_typ, 'Scancode':scancode_string, 'Wbm-orderno':ord_nmr, 'Wbm-HW-Version':v, 'Wbm-SF-Version':b,
'Wbm-mac-address':mac_addr, 'test-product-code':'Blank', 'combined-product-code':product_code, 'wbm-device-type':dev_typ, 'test-device-type':'Blank'})
when I open the csv file using Excel it SHOULD look like this:
But unfortunately my CSV file looks like this when i open it with Excel
As you can see all the values have gotten jam packed into one column instead of 1value:1column I would really appreciate it if you guys could show me how to do this. I think i am doing everything correctly but it still gets written only to one column. Please show me a solution for this problem if you guys can.