I want to append data into multiple columns of a csv file at a time.
I have defined a function "writeCSV" for it which is taking col_name and col_value to append in csv file.
def writeCSV(col_name,col_data):
with open('COMPONENT_DETAILS.csv',"a") as COMPONENT_DETAILS_file:
fieldnames = ['ID','module_name','module_id','tech_name','component_name','connecion','counter','connection_type']
csv_writer = csv.DictWriter(COMPONENT_DETAILS_file,fieldnames=fieldnames)
csv_writer.writerow({col_name:col_data})
Now, suppose I want to append data into columns- tech_name, component_name,connection_type, how should I pass the argument to writeCSV() function? Would dictionary be helpful here?
Right now, I can only append to only one column by calling function with below syntax,
writeCSV('tech_name': 'Python')