📅  最后修改于: 2022-03-11 14:45:25.980000             🧑  作者: Mango
import csv
with open("04122020_MCDXUV500REFBS4_01.dat") as infile, open("outfile.csv", "w") as outfile:
csv_writer = csv.writer(outfile)
prev = ''
csv_writer.writerow(['ID', 'PARENT_ID'])
for line in infile.read().splitlines():
csv_writer.writerow([line, prev])
prev = line