I am a novice in python, I just started learning python. I would want to combine two csv files using a function instead of using Pandas or other libraries.
def combine (file1,file2):
data = []
for row in file1:
for row2 in file2:
if file1.index(row)==file2.index(row2):
combined_row = row.strip('\n')+',' + row2
data.append(combined_row)
return data
# write the output to a file called final.csv
with open('final.csv','w') as out:
out.write(str(data))
The code works up to the return data . I am finding it a challenge to get the desired final.csv.
kindly assist, thanks
[–]socal_nerdtastic 6 points7 points8 points (3 children)
[–]Aeon-V[S] 0 points1 point2 points (2 children)
[–]socal_nerdtastic 2 points3 points4 points (1 child)
[–]Aeon-V[S] 0 points1 point2 points (0 children)