csvJsonExport Documentation
Purpose
The csvJsonExport function is designed to receive workflow data and convert it into downloadable file formats, specifically CSV, JSON, and Excel (in tab-separated values format). This enables user-friendly data export functionalities, making data easily portable for further processing or analysis.
Settings
The csvJsonExport logic includes several customizable settings that impact its behavior. Below is a detailed explanation of each setting:
-
format
- Input Type: Dropdown (options:
'csv','json','xlsx') - Description: Specifies the format of the exported file. Changing this setting determines how the data is structured and saved. For example, selecting
'json'will format the data as JSON objects, while selecting'csv'will produce a comma-separated values file. - Default Value:
'csv'
- Input Type: Dropdown (options:
-
filename
- Input Type: String
- Description: Allows users to specify a custom filename for the output file. If this field is left empty, a timestamp-based filename is auto-generated. Customizing this value can help in organizing and identifying exported files easily.
- Default Value: Auto-generated based on the current timestamp if left empty (format:
export_YYYY-MM-DDTHH-MM-SS).
-
delimiter
- Input Type: Dropdown (options:
',',';','\t') - Description: Specifies the character used to separate values in the CSV file. This setting only applies when the selected format is
'csv'. Changing this affects how individual values are delineated within the file; for example, selecting a semicolon would change the typical CSV delimiter. - Default Value:
','
- Input Type: Dropdown (options:
-
includeHeaders
- Input Type: Boolean
- Description: Determines whether to include the header row containing column names in the exported CSV file. Setting this to
falsewill omit the header and only export the data rows. This is useful for cases where header information is not required or for datasets designed to be processed without headers. - Default Value:
true
How It Works
The csvJsonExport function works by first resolving and unwrapping the input data, which may come from various upstream output formats. If the data is not an array or if it's empty, the function will return an empty export response. The data format (CSV, JSON, or XLSX) is determined by the config.format setting, and the specific data formatting (including delimiters and headers) is then handled accordingly.
- Input Handling: The function checks for valid input data. If the data is not an array or is empty, it returns an error response.
- Export Logic: Based on the specified format, the function constructs the content to be exported:
- For JSON, it serializes the data as JSON.
- For XLSX, it creates a tab-separated value format.
- For CSV, it constructs the CSV with proper escaping for delimiters and quotes.
- Return Result: The function returns the generated file type, filename, MIME type, content, row count, and the original data for downstream processing.
Data Expectations
The csvJsonExport logic expects the input data to be in a compatible format, likely coming from previous workflow nodes. The input should ideally be an array of objects where each object represents a row of data, with key-value pairs corresponding to the column names and their respective values.
- Input Example:
json
[ {"name": "Alice", "age": 30}, {"name": "Bob", "age": 25} ]
Use Cases & Examples
Use Cases
-
Data Sharing: A marketing team needs to share customer feedback data with external stakeholders in a standard format for analysis.
csvJsonExportcan help export this data in CSV format, making it easy to import into analysis tools. -
Data Backup: A data engineer wants to back up processed data to a JSON format for archival. Using
csvJsonExport, they can create a JSON file that retains the data structure for future processing. -
Reporting: A financial team requires a summary report that exports transaction records in an Excel-compatible format. The
csvJsonExportcan generate a tab-separated value file that can be opened in Excel.
Configuration Example
Use Case: Exporting customer data to a CSV file for distribution.
Configuration Data:
{
"inputs": {
"data": [
{"name": "Alice", "age": 30, "email": "alice@example.com"},
{"name": "Bob", "age": 25, "email": "bob@example.com"}
]
},
"config": {
"format": "csv",
"filename": "customer_data_export",
"delimiter": ",",
"includeHeaders": true
}
}Expected Output:
When the above configuration is executed, the result will be a CSV file named customer_data_export.csv with the following content:
name,age,email
"Alice",30,"alice@example.com"
"Bob",25,"bob@example.com"
AI Integrations
While there are no specific AI integrations associated with the csvJsonExport logic itself, the processes surrounding it can benefit from AI enhancements. For example, automated data analysis or predictions based on exported datasets could leverage machine learning algorithms to derive insights from the exported files.
Billing Impact
Utilizing the csvJsonExport function may have indirect billing impacts depending on the data volume processed and the number of executions. Users should be aware of their data service plan's capacities, as exporting large datasets may incur additional costs related to processing or data storage.
This extensive documentation is aimed at providing a thorough understanding of the csvJsonExport logic's capabilities, configurations, and use cases within the Vantage analytics and data platform.