Ask AI
Skip to main content

Generate data from csv

Function: Generate data from csv

This action allows you to transform the content of a CSV (Comma Separated Values) file into a structured list of items within your application. It's perfect for importing data from spreadsheets or other systems, making it usable for further processing, display, or storage. You define the structure of the data you expect, and the action will parse the CSV file accordingly.

Input

  • Data Structure: The blueprint or template that defines how each row of your CSV file should be interpreted. This tells the system what kind of information (e.g., text, numbers, dates) to expect in each column and what to name it. This input is required.
  • File: The CSV file you want to process. This file should be uploaded to your media library or provided from another action. This input is required.
  • Delimiter: The character used to separate values (columns) within your CSV file. Common delimiters include a comma (,), semicolon (;), or tab. The default value is ;. This input is required.
  • Header: A True/False setting indicating whether the first row of your CSV file contains column headers (names for each column). If set to True, the action will use these names to match with your Data Structure. If False, it will assume the first row is data. The default value is True.

Output

  • Name: The name of the variable that will hold the parsed data. This variable will contain a list of items, where each item matches the "Data Structure" you provided.

Execution Flow

Real-Life Examples

Example 1: Importing a Customer List

Imagine you have a CSV file with your customer details, and you want to import them into your application.

  • Inputs:
    • Data Structure: Customer Profile (defined with fields like FirstName (Text), LastName (Text), Email (Email), JoinDate (Date)).
    • File: customers.csv (uploaded to your media library).
    • Delimiter: , (comma).
    • Header: True (the first row of customers.csv contains FirstName,LastName,Email,JoinDate).
  • Result: A variable named ParsedCustomers is created, containing a list of customer profiles, each with their first name, last name, email, and join date, ready to be displayed or saved.

Example 2: Updating Product Inventory

You receive a daily inventory update as a text file, but it doesn't have a header row and uses a pipe | as a separator.

  • Inputs:
    • Data Structure: Product Item (defined with fields like ProductID (Number), ProductName (Text), Quantity (Number), Price (Double)).
    • File: inventory_update.txt (uploaded).
    • Delimiter: | (pipe).
    • Header: False (the file starts directly with data).
  • Result: A variable named UpdatedInventory is created, holding a list of product items, each with its ID, name, quantity, and price, which can then be used to update your product database.

Example 3: Processing Sales Transactions

Your sales team provides a weekly sales report in a CSV format, using semicolons to separate values.

  • Inputs:
    • Data Structure: Sales Record (defined with fields like TransactionID (Number), ItemSold (Text), Amount (Currency), SaleDate (Date)).
    • File: weekly_sales.csv (uploaded).
    • Delimiter: ; (semicolon).
    • Header: True (the first row contains TransactionID;ItemSold;Amount;SaleDate).
  • Result: A variable named WeeklyTransactions is created, containing a list of sales records, each detailing a transaction, item sold, amount, and sale date, which can be used for reporting or analytics.