-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathida_csv.py
More file actions
24 lines (19 loc) · 782 Bytes
/
ida_csv.py
File metadata and controls
24 lines (19 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# i want to read a CSV file which only got two coumns x,y
# then we want to write to a new file file_new.csv where we write "x","y"
introduction = """
\nHello, this Script will accept a CSV file with Content looking like
this : Firstname; Lastname . With this input it will convert it to the
following: \"Firstname\";\"Lastname\". The new file is called
<old_name>_new.csv \n """
print(introduction)
file_name = input("Please enter a filename : ")
new_file = file_name.strip(".csv") + "_new.csv"
with open(file_name) as f:
lines = f.readlines()
f.close()
with open(new_file, "w") as nf:
for line in lines:
line = line.rstrip()
to_write = line.split(";")
nf.write("\""+to_write[0]+"\"" + "," +"\"" +to_write[1] + "\"" + "\n")
nf.close()