“Python Convert Dat File ke CSV” Kode Jawaban

Python Convert Dat File ke CSV

import csv

with open("infile.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
Sparkling Starling

Python Convert Dat File ke CSV

import csv

with open("s0164-head-up-tilt.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
Long Lobster

Python Convert Dat File ke CSV

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
Hilarious Hare

Jawaban yang mirip dengan “Python Convert Dat File ke CSV”

Pertanyaan yang mirip dengan “Python Convert Dat File ke CSV”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya