1
열린 csv 파일의 내용을 csv 판독기를 통해 실행하기 전에 어떻게 편집 할 수 있습니까? 열린 csv 파일 편집
csvfile = open(input, mode='r', newline='', encoding='utf-8') # opening csv file
for line in csvfile:
line = line.replace(",", ";") #replacing comma with semicolon
print(line) # test if replace was successful (working)
csvfile.seek(0) # return to the beginning of the file
csv_read = csv.reader(csvfile, delimiter=";", quotechar='"') # use reader
이
내가 기대했던 및 csv.reader는 여전히 이전 편집되지 않은 파일을 읽고로 작동하지 않습니다.어떻게 해결할 수 있습니까?
원래 구분 기호를 사용하지 않는 이유는 무엇입니까? 'line ='은 루프에서 그 이름을 재 할당하기 만하면됩니다 ** ** 기본 파일을 변경하지 않습니다. – jonrsharpe
[Inline CSV File Editing with Python] 가능한 중복 (http://stackoverflow.com/questions/16020858/inline-csv-file-editing-with-python) – wwii