Skip to content

Commit fe1a0c5

Browse files
committed
formatted the code
1 parent 89c9145 commit fe1a0c5

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

CSV_to_JSON/csv_to_json.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,27 @@
33

44
file_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")

CSV_to_JSON/img/CLI.jpg

165 Bytes
Loading

CSV_to_JSON/img/after.jpg

2.5 KB
Loading

CSV_to_JSON/img/before.jpg

0 Bytes
Loading

0 commit comments

Comments
 (0)