File Management

Importing CSV Files with List of Enums Field

Summary

Hi, Z Community! It's Liz, your Developer Community Manager. Today, I'm guiding you on how to import a CSV file that contains fields with a list of enum (enumerated) values. This process is particularly useful when you're managing datasets with categorical fields.

Setting Up Your Database Table:

Before importing, ensure your Xano database table is properly configured:

  1. Text Field: This will store activities from our sports CSV.
  2. Season Field: A list of enum values, representing the different seasons in which an activity can be performed.

In our example, the `Season` field is set to contain all possible seasons as enum values.

Preparing the API Endpoint for Import:

Navigate to your API endpoint setup for CSV import:

  • The endpoint should have a File Resource as an input.
  • Utilize the CSV Stream function within the function stack to process the file.
  • Loop through each record and insert it into the designated table (e.g., `Sportscore V2`).

Important: When mapping the `Seasons` column to your `Season` field, apply the `Json decode` filter. This ensures the JSON-formatted list in your CSV translates correctly into Xano's enum list format.

Running the Import:

Let's execute the import:

  1. Select the sports CSV file.
  2. Run the API endpoint to process the file.

Upon successful execution, the records will be correctly imported into your Xano table, with enum fields accurately populated.

Reviewing the Imported Data:

Navigate to your table to review the imported records. Each entry should reflect the accurate enumeration for the `Season` field based on your CSV data.

Conclusion:

This tutorial should help you efficiently import CSV files with enum lists into your Xano database, ensuring data integrity and simplifying backend management for categorized information.

Looking forward to your feedback and questions! Let us know how this works for you in the comments, the community forum, or via the support link in Xano.

This transcript was AI generated to allow users to quickly answer technical questions about Xano.

Was this helpful?

I found it helpful

I need more support
Sign up for XanoSign up for Xano

Build without limits on a secure, scalable backend.

Unblock your team’s progress and create a backend that will scale for free.

Start building for free