Aerostack
bar_chart

data-csv-parse Edge Function — Data

Data

Parses a CSV string into an array of row objects with headers, handling quoted fields, custom delimiters, and escaped characters.

navin @navin verified
Updated Mar 12, 2026
GitHub

Edge function data-csv-parse Parses a CSV string into an array of row objects with headers, handling quoted fields, custom delimiters, and escaped characters.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.

terminal — aerostack cli
$ npx aerostack add navin/data-csv-parse
smart_toy

Use with AI Assistants

MCP

Connect Claude, Cursor, or any MCP-compatible client — then call this function by slug

① Add MCP Server

Add this once — access all Aerostack functions from your AI tool.

claude_desktop_config.json
{
  "mcpServers": {
    "aerostack": {
      "url": "https://mcp.aerostack.dev",
      "type": "http"
    }
  }
}

② Call this function

Ask your AI to use the call_function tool with this slug:

call_function
call_function({
  slug: "data-csv-parse",
  args: {
    "csv": "example_csv",
    "delimiter": ",",
    "hasHeader": true,
    "trimValues": true
  }
})

data-csv-parse — CSV string to row objects

Parses a CSV string into structured row objects, handling quoted fields, custom delimiters, and escaped characters.


API

POST /api/data-csv-parse

Request body

Field Type Required Default Description
csv string The CSV string to parse
delimiter string ',' Field delimiter
hasHeader boolean true First row is header
trimValues boolean true Trim whitespace from values

Success response (200)

{
  "success": true,
  "data": {
    "rows": [
      { "name": "Alice", "age": "30", "city": "NYC" }
    ],
    "headers": ["name", "age", "city"],
    "rowCount": 1
  }
}

Error responses

Code HTTP When
INVALID_INPUT 400 Missing csv field
INTERNAL_ERROR 500 Unexpected error

Usage

cURL
curl -X POST "$FUNCTION_URL" \
  -H "Content-Type: application/json" \
  -d '{"csv": "name,age\nAlice,30\nBob,25"}'
TypeScript / JavaScript (HTTP)
const response = await fetch(FUNCTION_URL, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ csv: csvString, delimiter: ';' }),
});
const { data } = await response.json();
console.log(data.rows);
Direct import (Node / Bun / Deno)
import { csvParse } from '@aerostack/functions/data-csv-parse';

const { rows, headers, rowCount } = csvParse({ csv: myCsvString });

Use Cases

  • Parsing user-uploaded CSV files for import into a database
  • Processing CSV exports from external services (CRMs, spreadsheets) in a workflow
  • Converting report data from CSV format into structured objects for further processing

Notes

  • Quoted fields containing delimiters, newlines, and escaped double quotes are handled correctly
  • Empty fields return empty string ""
  • When hasHeader=false, numeric string keys ("0", "1") are used as headers

Metadata

upgrade Version 1.0.0
gavel License MIT
language Language typescript
cloud Provider aerostack

Tags

data
deployed_code

Build and publish your own functions

Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.

More Data Functions

Browse Data Functions →

Frequently asked questions

What does the data-csv-parse function do? +

data-csv-parse is a serverless edge function for data automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.

How do I deploy the data-csv-parse function? +

Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/data-csv-parse ``` It will be live on Cloudflare Workers in seconds.

What runtime does data-csv-parse use? +

data-csv-parse runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.

Can I customise the data-csv-parse function? +

Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.