Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CSV_to_JSON/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Make sure you have python 3 or higher, that's it.

## Files
before<br/>
![before](https://github.com/TechBoyy6/Python-scripts-collection/blob/master/CSV_to_JSON/img/before.jpg)<br/>
![before](https://github.com/fnplus/Python-scripts-collection/blob/master/CSV_to_JSON/img/before.jpg?raw=true)<br/>

## CLI interface
![image](https://github.com/TechBoyy6/Python-scripts-collection/blob/master/CSV_to_JSON/img/CLI.jpg)
![image](https://github.com/fnplus/Python-scripts-collection/blob/master/CSV_to_JSON/img/CLI.jpg?raw=true)

## Files
After<br/>
![after](https://github.com/TechBoyy6/Python-scripts-collection/blob/master/CSV_to_JSON/img/after.jpg)
![after](https://github.com/fnplus/Python-scripts-collection/blob/master/CSV_to_JSON/img/after.jpg?raw=true)

## Contact
<a href="https://twitter.com/MoiZ__2001?s=08">
Expand Down
27 changes: 9 additions & 18 deletions CSV_to_JSON/csv_to_json.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
import csv
import json

file_name = input("Provide the CSV filename without extension>> ")
file_name = input("Provide the CSV filename : ")
if not file_name.strip().endswith(".csv"):
file_name += ".csv"

with open(file_name + '.csv') as f:
with open(file_name) as f:
reader = csv.reader(f, delimiter=",")

reader = csv.reader(f, delimiter=',')

titles = []
temp_data = {}

for heading in reader:
titles = heading
break

i = 1
titles = next(reader)
temp_data = []

for row in reader:
current_row = "row{}".format(i)
temp_data['{}'.format(current_row)] = {}
for col in range(len(titles)):
temp_data[current_row][titles[col]] = row[col]
i += 1
temp_data.append({col: val for col, val in zip(titles, row)})

with open(file_name + '.json', 'w') as f_j:
with open(file_name.strip()[:-4] + ".json", "w") as f_j:
json.dump(temp_data, f_j, indent=4)

print("File converted successfully :)\n")
10 changes: 6 additions & 4 deletions FindIPAddress/FindIPAddress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import socket
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
print("Your Computer Name is:" + hostname)
print("\nYour Computer IP Address is:" + IPAddr)

HostName = socket.gethostname()
IPAddr = socket.gethostbyname(HostName)

print(f"Your Computer Name is: {HostName}\n")
print(f"Your Computer IP Address is: {IPAddr}")