Ask AI
Skip to main content

Create csv file

Function: Create CSV File

This action allows you to generate a Comma Separated Values (CSV) file from a list of data records within your application. You define the structure of the data, how values should be separated, and whether to include a header row. This is useful for exporting data for reports, integrations, or external analysis.

Input

  • Dataformat
    • Type: DATA_FORMAT
    • Required: Yes
    • Description: The data structure that defines the columns and types of data expected in your CSV file. This ensures your data is correctly organized.
  • Delimiter
    • Type: STRING
    • Required: Yes
    • Default Value: ;
    • Description: The character used to separate individual values (columns) within each row of the CSV file. Common delimiters include a comma (,) or a semicolon (;).
  • Enable Header
    • Type: BOOLEAN
    • Required: Yes
    • Default Value: true
    • Description: Choose whether to include a header row at the very top of your CSV file. This row typically contains the names of your columns, making the data easier to understand.
  • Use firstrow
    • Type: BOOLEAN
    • Required: No
    • Default Value: false
    • Description: If enabled, the column names for the header (if "Enable Header" is true) will be automatically determined from the keys of the first data record in your "Rows" list. If disabled, the "Dataformat" you selected will define the column names.
  • Rows
    • Type: ARRAY
    • Required: Yes
    • Description: The list of data records (objects) that you want to convert into rows in your CSV file. Each item in this list will become a new row.

Output

  • File
    • Type: FILE
    • Description: The generated CSV file. This file will be stored in a variable named FILE_NAME in your application's scope, ready for further actions like saving, sending, or displaying.

Execution Flow

Real-Life Examples

Example 1: Exporting Customer Contact List

Imagine you have a list of customer records in your application and you want to export them to a CSV file for your sales team to use in a spreadsheet.

  • Inputs:
    • Dataformat: CustomerContactSchema (a predefined data structure with fields like FirstName, LastName, Email, Phone)
    • Delimiter: , (comma)
    • Enable Header: True
    • Use firstrow: False
    • Rows: [ \{ "FirstName": "Alice", "LastName": "Smith", "Email": "[email protected]", "Phone": "555-1234" \}, \{ "FirstName": "Bob", "LastName": "Johnson", "Email": "[email protected]", "Phone": "555-5678" \} ]
  • Result: A CSV file is generated, stored in the FILE_NAME variable. This file contains two rows of customer data, with a header row (FirstName,LastName,Email,Phone) and values separated by commas.

Example 2: Generating a Sales Report with Semicolon Delimiter

You need to create a daily sales report in CSV format, where the data fields are separated by semicolons, as required by an external system.

  • Inputs:
    • Dataformat: DailySalesReportSchema (with fields like Date, Product, Quantity, Revenue)
    • Delimiter: ; (semicolon)
    • Enable Header: True
    • Use firstrow: False
    • Rows: [ \{ "Date": "2023-10-26", "Product": "Laptop", "Quantity": 2, "Revenue": 2400.00 \}, \{ "Date": "2023-10-26", "Product": "Mouse", "Quantity": 10, "Revenue": 150.00 \} ]
  • Result: A CSV file is generated, stored in the FILE_NAME variable. This file contains the sales data, including a header row, with each field separated by a semicolon.

Example 3: Simple Data Export without Header, inferring columns from first row

You have a simple list of product details and want to quickly export them to a CSV without a formal header, but you want the columns to be ordered based on the first product's properties.

  • Inputs:
    • Dataformat: ProductDetailsSchema (a basic schema that matches the product object structure)
    • Delimiter: , (comma)
    • Enable Header: False
    • Use firstrow: True
    • Rows: [ \{ "ID": "P001", "Name": "Widget A", "Price": 10.50 \}, \{ "ID": "P002", "Name": "Gadget B", "Price": 25.00 \} ]
  • Result: A CSV file is generated, stored in the FILE_NAME variable. This file contains the product data without a header row. The columns are implicitly ordered as ID, Name, Price based on the first product object, and values are separated by commas.