Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
1文字ずつ書き込まれる謎
import csv
input_file = open('example.csv')
output_file = open('copycsv.csv', 'w', newline='')
input_reader = csv.reader(input_file)
output_writer = csv.writer(output_file)
for i in input_reader:
output_writer.writerow(i)
output_writer.writerow(str(i))
output_file.close()
input_file.close()
@kotoripiyopiyo

This comment has been minimized.

Copy link
Owner Author

@kotoripiyopiyo kotoripiyopiyo commented Feb 11, 2021

example.csv中身:
4/5/2014 13:34,Apples,73
4/5/2014 3:41,Cherries,85
4/6/2014 12:46,Pears,14
4/8/2014 8:59,Oranges,52
4/10/2014 2:07,Apples,152
4/10/2014 18:10,Bananas,23
4/10/2014 2:40,Strawberries,98

copycsv.csv中身:
4/5/2014 13:34,Apples,73
[,',4,/,5,/,2,0,1,4, ,1,3,:,3,4,',",", ,',A,p,p,l,e,s,',",", ,',7,3,',]
4/5/2014 3:41,Cherries,85
[,',4,/,5,/,2,0,1,4, ,3,:,4,1,',",", ,',C,h,e,r,r,i,e,s,',",", ,',8,5,',]
4/6/2014 12:46,Pears,14
[,',4,/,6,/,2,0,1,4, ,1,2,:,4,6,',",", ,',P,e,a,r,s,',",", ,',1,4,',]
4/8/2014 8:59,Oranges,52
[,',4,/,8,/,2,0,1,4, ,8,:,5,9,',",", ,',O,r,a,n,g,e,s,',",", ,',5,2,',]
4/10/2014 2:07,Apples,152
[,',4,/,1,0,/,2,0,1,4, ,2,:,0,7,',",", ,',A,p,p,l,e,s,',",", ,',1,5,2,',]
4/10/2014 18:10,Bananas,23
[,',4,/,1,0,/,2,0,1,4, ,1,8,:,1,0,',",", ,',B,a,n,a,n,a,s,',",", ,',2,3,',]
4/10/2014 2:40,Strawberries,98
[,',4,/,1,0,/,2,0,1,4, ,2,:,4,0,',",", ,',S,t,r,a,w,b,e,r,r,i,e,s,',",", ,',9,8,',]

なぜこうなるのか‥理由不明

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment