我关注的过程是 -
有没有直接的方法将Avro文件转换为CSV?
答案 0 :(得分:0)
这是我将avro文件转换为csv的方式:
from fastavro import reader
import csv
head = True
count = 0
f = csv.writer(open("test.csv", "w+"))
with open('abc.avro', 'rb') as fo:
avro_reader = reader(fo)
for emp in avro_reader:
#print(emp)
if head == True:
header = emp.keys()
f.writerow(header)
head = False
count += 1
f.writerow(emp.values())
print(count)