so i have this issue where i must make a program where you input the file names which then merge together into a new file keeping the same column names e.g.
A 1
B 2
C 3
D 4
A Monday
B Tuesday
C Wednesday
D Thursday
what i want it to do is:
A 1 Monday
B 2 Tuesday
C 3 Wednesday
D 4 Thursday
what i'm getting is:
[""A","B","C","D""],[""1","2","3","4""],[""Monday","Tuesday","Wednesday","Thursday""]
Here is my code:
thanks James
here is the other way where it goes
A 1
B 2
C 3
D 4
A Monday
B Tuesday
C Wednesday
D Thursday
what i want it to do is:
A 1 Monday
B 2 Tuesday
C 3 Wednesday
D 4 Thursday
what i'm getting is:
[""A","B","C","D""],[""1","2","3","4""],[""Monday","Tuesday","Wednesday","Thursday""]
Here is my code:
import csv print("Please input the first file location you would like to merge") #file1 = input() file1 = ("CLI1.csv") print("Please now input the second file location") #file2 = input() file2 = ("Company1.csv") rows = [] for f in ("CLI1.csv"): readera = csv.reader(open(file1,"r")) for row in readera: rows.append(row) for g in ("company1.csv"): readerb = csv.reader(open(file2,"r")) for row in readerb: rows.append(row) rows = str(rows) writer = csv.writer(open("merge.csv", "w"),delimiter=' ') print("Done") quit()does anyone have any suggestions on what i need to change for this to work?
thanks James
here is the other way where it goes
Output:A
B
C
D
1
2
3
4
M
o
n
d
a
y
T
u
e
s
d
a
y
W
e
d
n
e
s
d
a
y
t
h
u
r
s
d
a
y
import csv num = True print("Please input the first file location you would like to merge") #file1 = input() file1 = ("CLI1.csv") print("Please now input the second file location") #file2 = input() file2 = ("Company1.csv") datadict = [] for f in ("CLI1.csv"): readera = csv.reader(open("CLI1.csv","r")) for row in readera: datadict.append(row) #print(datadict) for g in ("company1.csv"): readerb = csv.reader(open("company1.csv","r")) for row in readerb: datadict.append(row) #print(datadict) datadict = str(datadict) writer = csv.writer(open("merge.csv", "w"),delimiter=' ') ##writer.writerow(''[rows])num=num+1 while num==True: writer.writerow("\n".join(datadict)) else: writer.writerow("".join(datadict)) num = False print("Done") quit()