Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

How to read .avro file in Alteryx

Yuk_Sha
6 - Meteoroid

.avro datatype is not compatible with the 2021 Alteryx version hence the file can be converted to .csv format using the below python code-

 

import fastavro

import csv

 

def convert_avro_to_csv(avro_file, csv_file):

    # Read the Avro file using fastavro library

    with open(avro_file, 'rb') as avro_data:

        avro_reader = fastavro.reader(avro_data)

        avro_schema = avro_reader.writer_schema

        avro_records = list(avro_reader)

 

    # Extract the Avro field names from the schema

    field_names = [field['name'] for field in avro_schema['fields']]

 

    # Write the Avro records to a CSV file

    with open(csv_file, 'w', newline='', encoding="utf-8") as csv_data:

        writer = csv.DictWriter(csv_data, fieldnames=field_names)

        writer.writeheader()

        writer.writerows(avro_records)

 

# Example usage

convert_avro_to_csv(avro_file, csv_file)

 

Post conversion the csv file can be read in alteryx as normal.

1 REPLY 1
apathetichell
20 - Arcturus

I believe that Alteryx is natively compatable with Avro. 2021.4 is at least.

Labels
Top Solution Authors