所以,我试图将[0,1,2,9,10]行从我指定的“e\u文件”转移到“no\u文件”
当我打印“数据”时,我得到了我想要的确切信息,我只是想知道如何将这些数据传输到相应的CSV文件
谢谢你
e_file = '/Users/massive/Desktop//NO/hour.csv'
no_file = '/Users/massive/Desktop/NO/combined.csv'
with open(e_file,'r') as e_r:
state_code = input("Enter state code: ")
county_code = input("Enter county code: ")
station_number = input("Enter station number: ")
csv_reader_2 = csv.reader(e_r)
for row in csv_reader_2:
if row[0] == str(state_code).zfill(2) and row[1] ==str(county_code).zfill(3) and row[2] == str(station_number).zfill(4):
data = [row[0],row[1],row[2],row[9],row[10]]
print(data)
可能是这样的(除非您提供一个工作示例,否则我无法测试它):
相关问题 更多 >
编程相关推荐