我试图用'NA'填充csv文件的空白列。我可以用熊猫做到这一点。但是我不想用熊猫。在不使用熊猫的情况下写入csv时该如何做?
from itertools import zip_longest
import csv
import time
import pandas as pd
index = []
time_stamp = []
image_link_list = []
for i in range(5):
i += 1
index.append(i)
time_stamp.append(int(time.time()))
compilation = [index, image_link_list, time_stamp]
data_collection = zip_longest(*compilation, fillvalue='')
with open('sample.csv', 'w', newline='') as file:
csv_writer = csv.writer(file, delimiter=',')
csv_header = csv_writer.writerow(['ID', 'IMAGE_LINK', 'TIME_STAMP'])
csv_rows = csv_writer.writerows(data_collection)
csv.fillna()
请帮助我更正代码。