I am very new to programming how can I write the header only once but the other values repeatedly i am not sure what terms to use to describe this so i will show you what i mean:
toWriteHeader = [
["Timestamp:", "Overall result:","Blank", "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:","combined-product-code:", "wbm-device-type:"],
]
toWrite = [
[now ,"Blank",d_ordernum,d_hw_version,d_sf_version,pc_praefix,d_dev_typ,scancode_string,ord_nmr,ord_nmr,v,b]
]
file = open('Test.csv', 'w')
with file:
writer = csv.writer(file)
for row in toWriteHeader:
writer.writerow(row)
file = open('Test.csv', 'a')
with file:
writer = csv.writer(file)
for row in toWrite:
writer.writerow(row)
so basically "writeToHeader" only needs to be written once but the other values need to be repeatedly appended but that does not happen I it is only writting "toWrite" once
can anyone suggest andy solutions or show me an example please. PS: go easy on me i am a beginner
Example output to the file:
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:,combined-product-code:,wbm-device-type:
2021-04-26 13:32:11,Blank,58184,1.00,1.0.0,7A2F7,TREE M-5TX PN IP67,58183#99AF0M000F9EF41A80,58184,58184,1.00,1.0.0
2021-04-26 13:32:32,Blank,58184,1.00,1.0.0,7A2F7,TREE M-5TX PN IP67,58183#99AF0M000F9EF41A80,58184,58184,1.00,1.0.0
2021-04-26 13:32:38,Blank,58184,1.00,1.0.0,7A2F7,TREE M-5TX PN IP67,58183#99AF0M000F9EF41A80,58184,58184,1.00,1.0.0
2021-04-26 13:33:48,Blank,58184,1.00,1.0.0,7A2F7,TREE M-5TX PN IP67,58183#99AF0M000F9EF41A80,58184,58184,1.00,1.0.0
2021-04-26 13:33:55,Blank,58184,1.00,1.0.0,7A2F7,TREE M-5TX PN IP67,58183#99AF0M000F9EF41A80,58184,58184,1.00,1.0.0
My Current Output to the file:
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:,combined-product-code:,wbm-device-type:
2021-04-26 13:32:11,Blank,58184,1.00,1.0.0,7A2F7,TREE M-5TX PN IP67,58183#99AF0M000F9EF41A80,58184,58184,1.00,1.0.0