File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44file_name = input ("Provide the CSV filename without extension>> " )
55
6-
7-
8- with open (file_name + '.csv' ) as f :
6+ with open (file_name + '.csv' ) as f :
97
108 reader = csv .reader (f , delimiter = ',' )
119
1210 titles = []
1311 temp_data = {}
1412
1513 for heading in reader :
16- print (heading )
1714 titles = heading
1815 break
1916
2017 i = 1
2118
2219 for row in reader :
23- print (row )
2420 current_row = "row{}" .format (i )
2521 temp_data ['{}' .format (current_row )] = {}
2622 for col in range (len (titles )):
2723 temp_data [current_row ][titles [col ]] = row [col ]
28- i += 1
24+ i += 1
2925
30- with open (file_name + '.json' , 'w' ) as f_j :
26+ with open (file_name + '.json' , 'w' ) as f_j :
3127 json .dump (temp_data , f_j , indent = 4 )
3228
33- print ("File converted successfully :)" )
29+ print ("File converted successfully :)\n " )
You can’t perform that action at this time.
0 commit comments