1. Overview
The Csv tool is a powerful built-in utility designed for data transformation within GoInsight. Its core function is to facilitate seamless conversion between two of the most common data formats: CSV (Comma-Separated Values) and JSON (JavaScript Object Notation).
With the GoInsight Csv node, you can easily integrate data format conversions into your automated workflows. This is particularly useful when interacting with different APIs or services that require data in a specific format. The primary capabilities include:
- Parsing CSV Data: Convert raw CSV text into a structured JSON array, making it easy to iterate over and process individual records in subsequent workflow steps.
- Generating CSV Data: Transform a JSON array of objects into a standard CSV text format, complete with a header row, ready for export or use in systems that require CSV input.
2. Prerequisites
No special prerequisites are required to use this node. It is a built-in utility available in all GoInsight workflows.
3. Credentials
For a detailed guide on how to obtain and configure credentials, please refer to our official documentation: Credentials Configuration Guide.
4. Supported Operations
The Csv node provides operations for converting data between CSV and JSON formats.
Summary
| Resource | Operation | Description |
|---|---|---|
| Data Conversion | Convert CSV to JSON | Converts CSV text into JSON format. |
| Data Conversion | Convert JSON to CSV | Converts a JSON string to CSV format, including a header row and using a comma as the delimiter. |
Operation Details
Convert CSV to JSON
Converts CSV text into JSON format.
Input Parameters:
- CSVText: The CSV content as text.
Options:
- HasHeaders: Indicates whether the first row is headers.
- UseCommaDelimiter: True to use comma as delimiter, False to use tab as delimiter.
Output:
- JSON (string): A JSON string representing the converted data, empty string if conversion fails.
- Success (bool): Indicates whether the conversion was successful.
- ErrorMessage (string): Error message describing why the conversion failed.
Convert JSON to CSV
Converts a JSON string to CSV format, including a header row and using a comma as the delimiter.
Input Parameters:
- JSONText: A JSON string representing an array of objects to convert.
Output:
- CSV (string): The resulting CSV string with a header row, fields separated by commas.
- Success (bool): Indicates whether the conversion was successful.
- ErrorMessage (string): Error message describing why the conversion failed.
5. Example Usage
This section will guide you through creating a simple workflow to convert a block of CSV text into a structured JSON array.
The workflow will consist of three nodes: Start -> Convert CSV to JSON -> Answer.
- Add the Csv Node
- In the workflow canvas, click the "+" icon to add a new node.
- In the panel that appears, select the "Tools" tab.
- Find and select "Csv" from the list of tools.
- From the list of supported operations for Csv, click on "Convert CSV to JSON" to add the node to your canvas.
- Configure the Node
- Click on the newly added "Convert CSV to JSON" node to open its configuration panel on the right.
- Credentials: This tool is a built-in utility and does not require any credentials to be configured.
- Parameters: Fill in the input parameters as follows:
- CSVText: Enter the raw CSV data you want to convert. This can be static text, or more commonly, a variable from a previous step (e.g., the output of an HTTP Request node). For this example, you can paste the following text:
- HasHeaders: Since our sample data includes a header row ("ID","Name","Email"), turn this toggle on (set to true). This will use the first row as keys in the resulting JSON objects.
- UseCommaDelimiter: Our data is comma-separated, so leave this toggle on its default setting (true).
- Run and Validate
- Once all required parameters are filled, any error indicators on the workflow canvas should disappear.
- Click the "Run" button in the top-right corner of the canvas to execute the workflow.
- After a successful run, you can click the log icon in the top-right corner to view the detailed input and output of the node. You will see the JSON output field containing the structured JSON array converted from your CSV text.
After completing these steps, your workflow is fully configured. When executed, it will take the provided CSV string, convert it into a JSON array, which can then be used by subsequent nodes in your workflow.
6. FAQs
Q: My CSV to JSON conversion is failing with Success as false. What should I check?
A: This is often due to malformed CSV data. Please check the following:
- Consistent Columns: Ensure every row in your CSV text has the same number of columns.
- Quoting: If your data contains commas, newlines, or quotes, make sure it is properly quoted (e.g., "this field, has a comma").
- Delimiter: Double-check that you have selected the correct delimiter (UseCommaDelimiter option) that matches your data.
Q: What format must the JSON be in for the "Convert JSON to CSV" operation?
A: The input JSONText must be a valid JSON string representing an array of flat objects. The keys of the first object in the array will be used to generate the header row of the CSV.
- Correct Example: [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
- Incorrect Example (not an array): {"id": 1, "name": "Alice"}
- Incorrect Example (nested objects): [{"user": {"id": 1, "name": "Alice"}}] (Nested objects are not supported for direct conversion).
Q: Does the "Convert JSON to CSV" operation support delimiters other than a comma?
A: Currently, the Convert JSON to CSV operation is standardized to output CSV text using a comma as the delimiter.
7. Official Documentation
As a built-in utility, the Csv tool's functionality is fully described within this document. For more general information on data transformation and manipulation within GoInsight, please refer to our main documentation platform.
Leave a Reply.