Oct-04-2020, 02:28 PM
i'm trying to take a .CSV file and write its data into another file,
i don't wanna copy the file, if you'll look at my code you'll probably see what i'm trying to do...
here's the code:
i checked allot of websites, no where to find a way...
I appreciate your help
Tal
i don't wanna copy the file, if you'll look at my code you'll probably see what i'm trying to do...
here's the code:
import csv file_input = '/home/tal/code/AAPL.csv' file_output = '/home/tal/code/file_output.txt' with open(file_input, 'r') as csv_file: reader = csv.reader(csv_file) for line in reader: with open(file_output, 'w') as file_op: file_op.write(line)this is the ouput when i debug it:
Output:Traceback (most recent call last):
File "/home/tal/.config/JetBrains/PyCharmCE2020.2/scratches/scratch.py", line 12, in <module>
file_op.write(line)
TypeError: write() argument must be str, not list
but i don't know how to convert the CSV data into a string...i checked allot of websites, no where to find a way...
I appreciate your help
Tal