Monetize360
WorkflowsFunctionsSystem Functions

Parse CSV/Excel File

Parse CSV and Excel files from file storage and convert them to JSON format

Parse CSV/Excel File

Parse CSV and Excel files from the file storage system and convert them to JSON format. The function automatically detects file type and handles headers, making it easy to process spreadsheet data in workflows.

Technical Name: ParseCSVMFunction

Properties

  • Execution Mode: SYNC
  • Type: NATIVE
  • Category: System Functions
  • Function ID: 990807b7-c819-447d-887b-4921390679ac

Input Schema

Required Parameters

ParameterTypeDescription
fileIdstring (uuid)UUID of the file to parse (must exist in file storage)

Optional Parameters

ParameterTypeDescription
hasHeaderbooleanWhether the file has a header row (default: true)
sheetIndexintegerFor Excel files, the sheet index to parse (0-based, default: 0)

[Image placeholder: ParseCSV function configuration panel]

Input Example

Parse CSV with Headers

{
  "fileId": "a7b9c4d2-3e5f-4a1b-9c8d-7e6f5a4b3c2d",
  "hasHeader": true
}

Parse CSV without Headers

{
  "fileId": "a7b9c4d2-3e5f-4a1b-9c8d-7e6f5a4b3c2d",
  "hasHeader": false
}

Parse Excel File (Specific Sheet)

{
  "fileId": "b8c0d5e3-4f6g-5b2c-d9e8-8f7g6c5d4e3f",
  "hasHeader": true,
  "sheetIndex": 1
}

Output Schema

FieldTypeDescription
headersarray (string)Column headers from the first row (only if hasHeader is true)
rowsarray (object)Array of parsed row objects, where each object contains column names as keys

Each object in the rows array contains:

  • Column names as keys (from headers if hasHeader=true, or "Column1", "Column2", etc. if hasHeader=false)
  • Cell values as string values

Output Example

With Headers

{
  "headers": ["Name", "Email", "Age"],
  "rows": [
    {
      "Name": "John Doe",
      "Email": "john@example.com",
      "Age": "30"
    },
    {
      "Name": "Jane Smith",
      "Email": "jane@example.com",
      "Age": "25"
    }
  ]
}

Without Headers

{
  "rows": [
    {
      "Column1": "John Doe",
      "Column2": "john@example.com",
      "Column3": "30"
    },
    {
      "Column1": "Jane Smith",
      "Column2": "jane@example.com",
      "Column3": "25"
    }
  ]
}

[Image placeholder: Parsed data visualization]

Supported File Types

  • CSV files (.csv, text/csv, text/plain)
  • Excel files (.xlsx, .xls, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)

How It Works

  1. File Detection: Automatically detects file type based on MIME type or file extension
  2. Header Processing:
    • If hasHeader=true: Uses first row as column names
    • If hasHeader=false: Generates column names like "Column1", "Column2", etc.
  3. Data Parsing:
    • CSV: Parses using UTF-8 encoding
    • Excel: Supports both .xlsx and .xls formats, converts cell values to strings
  4. Data Normalization: All values are converted to strings, missing cells are filled with empty strings

Use Cases

Process Uploaded CSV File

Parse a CSV file uploaded by a user:

{
  "fileId": "{{context.uploadedFileId}}",
  "hasHeader": true
}

Import Data from Excel

Parse a specific sheet from an Excel file:

Start → UploadFile → ParseCSV(sheetIndex: 1) → ForEach(InsertMData) → End

Process File Without Headers

Parse a file without header row:

{
  "fileId": "file-uuid",
  "hasHeader": false
}

[Image placeholder: Workflow examples]

Excel Sheet Index

For Excel files, use sheetIndex to specify which sheet to parse:

  • 0 - First sheet (default)
  • 1 - Second sheet
  • 2 - Third sheet
  • And so on...

Error Handling

File Not Found

{
  "error": "Error parsing file: File not found with ID: invalid-uuid"
}

Unsupported File Type

{
  "error": "Error parsing file: Unsupported file type: application/pdf"
}

Best Practices

  1. Always check fileId exists before parsing
  2. Set hasHeader correctly to ensure proper column mapping
  3. For Excel files, verify sheet index exists (0-based)
  4. Handle empty files gracefully in your workflow
  5. Validate parsed data before processing further