Nov-06-2017, 08:17 AM
hi,
i have a csv file (attached the file with the name python_dictionary.csv)
in the attached format has three columns Key, value1 and value2.. how can i manipulate csv using python so that i can make value1 as there headers.
this is desired format(for more details please refer desiredformat.csv)
key would be different in each case.
i am not able to go beyond because i dont know how to make permanent headers
i have a csv file (attached the file with the name python_dictionary.csv)
in the attached format has three columns Key, value1 and value2.. how can i manipulate csv using python so that i can make value1 as there headers.
this is desired format(for more details please refer desiredformat.csv)
key would be different in each case.
i am not able to go beyond because i dont know how to make permanent headers
import csv
filename = "python_dictionary.csv"
prj = {}
#fdata = dict()
#f = open(filename, "r")
data = f.read()
lst = data.split("\n")
for i in range(1, len(lst)):#because 0 is the header
val = lst[i].split(",")can anyone please guide?
Attached Files
