第一版:
import csv
file_path = "F:/zmz_experiment_data/dataset/train.csv"
with open(file_path,'r') as csvfile,open(file_path = "F:/zmz_experiment_data/dataset/train.txt") as f:
reader = csv.reader(csvfile)
for row in reader:
print(row[0],row[1],file = f)
简化版:
with open(file.csv, 'r') as f1,open(file.txt,'w') as f2:
for line in f1:
print(line.strip(),file = f2)
train.csv结构如下: