# csv2array: Convert a CSV to Array of Objects

> csv2array (Convert a CSV to Array of Objects) is a 1001fx API function in the group Files & PDF: POST https://api.1001fx.com/files/csv2array, 3 credits per call. It works as a ready-made module in Make and n8n or as a plain HTTP call.

Converts a csv and parse it into an array of objects. The file must be a valid csv file (not an Excel or GSheet spreadsheet).

- Group: Files & PDF
- Endpoint: `POST https://api.1001fx.com/files/csv2array`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: multipart/form-data
- Credits: 3 credits per call
- Ready-made in: Make and n8n
- Docs: https://1001fx.com/functions/csv2array

## Parameters

- `file` (file, required) – CSV file: Could be a comma or tab separated file format.
- `header` (boolean, optional, default `true`) – First row is header: If true, the first row of the data will be interpreted as field names for the result. Default is true.
- `dynamicTyping` (boolean, optional, default `true`) – Use dynamic typing: If true, numeric and boolean data will be converted to their type instead of remaining strings. Numeric data must conform to the definition of a decimal literal.Numerical values greater than 2^53 or less than - 2 ^ 53 will not be converted to numbers to preserve precision. Decimal delimiter has to be a '.' Default is true.

## Use cases

- Import a CSV export from a shop system into a database row by row
- Read a tab-separated report from an email attachment and loop over the lines
- Turn a CSV file from an FTP server into JSON for a CRM update

## Example: Semicolon CSV with header

```bash
curl -X POST 'https://api.1001fx.com/files/csv2array' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -F 'file=@csv.csv' \
  -F 'header=true' \
  -F 'dynamicTyping=true'
```

Answer (HTTP 200):

```json
{
  "result": [
    {
      "name": "Alice",
      "score": 1
    },
    {
      "name": "Bob",
      "score": 2.12
    },
    {
      "name": "Charlie",
      "score": "4,00"
    },
    {
      "name": "Dave",
      "score": "8.888,88"
    },
    {
      "name": "Eve",
      "score": "16,123"
    }
  ],
  "full": {
    "data": [
      {
        "name": "Alice",
        "score": 1
      },
      {
        "name": "Bob",
        "score": 2.12
      },
      {
        "name": "Charlie",
        "score": "4,00"
      },
      {
        "name": "Dave",
        "score": "8.888,88"
… (20 more lines)
```

## FAQ

**Can I upload an Excel or Google Sheets file?**

No. The file must be a real CSV or TSV file. Export the sheet as CSV first.

**Which separators are supported?**

Comma, semicolon and tab separated files are detected.

**Why are some numbers returned as text?**

With dynamicTyping numbers are converted only if they are decimal literals such as 2.12. Values with a decimal comma like 4,00 stay strings.
