Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[-]
Welcome
You have to register before you can post on our site.

Username:


Password:





[-]
Discord Widget

[-]
Twitter: SickGaming

[-]
Latest Threads
[Tut] 3 Simple Steps to Convert calendar...
Last Post: xSicKxBot
Today 12:58 AM
» Replies: 0
» Views: 0
[Tut] Add Google reCaptcha V3 Example wi...
Last Post: xSicKxBot
Today 12:58 AM
» Replies: 0
» Views: 0
(Free Game Key) Cook, Serve, Delicious! ...
Last Post: xSicKxBot
Today 12:58 AM
» Replies: 0
» Views: 0
PC - Frogun
Last Post: xSicKxBot
Today 12:57 AM
» Replies: 0
» Views: 0
[Tut] How to Sort Words Alphabetically i...
Last Post: xSicKxBot
Yesterday 05:51 AM
» Replies: 0
» Views: 0
PC - The Sims 4: High School Years
Last Post: xSicKxBot
Yesterday 05:51 AM
» Replies: 0
» Views: 0
News - Edgar Allan Poe Horror Biopic Rav...
Last Post: xSicKxBot
Yesterday 05:51 AM
» Replies: 0
» Views: 0
[Oracle Blog] Announcing GraalVM Enterpr...
Last Post: xSicKxBot
08-10-2022 12:05 PM
» Replies: 0
» Views: 0
[Tut] Best Solidity Linter
Last Post: xSicKxBot
08-10-2022 12:05 PM
» Replies: 0
» Views: 0
[Tut] JavaScript Autocomplete TextBox (a...
Last Post: xSicKxBot
08-10-2022 12:05 PM
» Replies: 0
» Views: 0

[Tut] How to Convert Avro to CSV in Python?

#1
How to Convert Avro to CSV in Python?

4/5 – (1 vote)

πŸ’¬ Question: How to convert an .avro file to a .csv file in Python?

Solution:

To convert an Avro file my_file.avro to a CSV file my_file.csv, create a CSV writer using the csv module and iterate over all rows using the iterator returned by fastavro.reader(). Then write each row to a file using the writerow() function.

Here’s an example:

from fastavro import reader
import csv with open('my_file.avro', 'rb') as file_object: csv_file = csv.writer(open("my_file.csv", "w+")) head = True for x in reader(file_object): if head: # write header header = emp.keys() csv_file.writerow(header) head = False # write normal row csv_file.writerow(emp.values())

Related: This code is a modified and improved version of this source.

πŸ’‘ Avro is a data serialization framework for RPCs (remote procedure calls) that uses JSON and binary format to serialize data.

πŸ’‘ CSV stands for comma-separated values, so you have a row-based file format where values are separated by commas, and the file is named using the suffix .csv.



https://www.sickgaming.net/blog/2022/08/...in-python/
Reply





Users browsing this thread:
1 Guest(s)

πš‚Μ·πš’Μ·πšŒΜ·πš”Μ·π™ΆΜ·πšŠΜ·πš–Μ·πš’Μ·πš—Μ·πšΜ· π™·Μ·πš˜Μ·πš–Μ·πšŽΜ·

Copyright Β© SickGaming.net 2022