我有一个记事本文件和一个csv文件。我想从记事本文件中提取“new\u password”数据,并使用python将其粘贴到csv文件的password列中。请参考附件并帮助我使用python代码。我成功地将整个文本文件内容写入csv文件的密码列中,但我只想将新的密码数据写入csv文件。你知道吗
import csv
f1 = open ("format.txt","r") # open input file for reading
for i in f1.readlines()[1:]:
if ';' in i:
temp=i.split(';')
f1 = temp[1]
with open('out.csv', 'wb') as f: # output csv file
writer = csv.writer(f)
with open('passwords_sample.csv','r') as csvfile: # input csv file
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
row[4] = f1.readlines() # edit the 8th column
writer.writerow(row)
f1.close()
目前没有回答
相关问题 更多 >
编程相关推荐