Piloterr

Files

Upload a CSV, spreadsheet or JSON file, choose its sheet and header line, read it again, or upload a big file straight to storage.

Dataflow reads CSV, TSV, TXT, XLSX, XLS, ODS, Numbers, JSON and NDJSON files, up to 50 MB and 100,000 rows.

curl https://dataflow.piloterr.com/v1/inputs \
  -H "x-api-key: YOUR_API_KEY" \
  -F file=@companies.xlsx \
  -F sheet=Leads \
  -F header=2 \
  -F dedupe=true

The answer describes what Dataflow found:

{
  "id": "4f1c2a9e-…",
  "filename": "companies.xlsx",
  "columns": ["company", "website"],
  "row_count": 18432,
  "sample": [{ "company": "Stripe", "website": "stripe.com" }],
  "sheets": ["Leads", "Archive"],
  "stats": {
    "empty_rows": 12,
    "duplicate_rows": 40,
    "deduplicated": true,
    "row_error_count": 0,
    "row_errors": []
  }
}

The answer is 201. Use the id as the project's input: {"type": "file", "input_id": "4f1c2a9e-…"}. sample holds the first 10 rows; sheets is empty for a text file. Send the file in the file field: without it, the answer is 422 validation_failed. A request over 50 MB is refused before it is read (413 input_too_large).

Options

FieldDefaultEffect
sheetThe first sheetThe sheet to read in a spreadsheet. sheets lists them all.
header1The line holding the column names, counted from 1 over non-empty lines, up to 100. Lines above it are skipped. 0 when there is none: columns are then column_1, column_2…
dedupefalseDrop rows identical to an earlier one.

How a file is read

  • Column names. A blank name becomes column_N (N is its position). A repeated name gets a suffix: email, email_2, email_3.
  • Values. Every value is text, trimmed. Plain-text formats keep values as typed, so 00123 stays 00123. Spreadsheet cells are read as the sheet shows them, and formulas are never evaluated: Dataflow reads the value the file saved.
  • Empty rows are skipped and counted in stats.empty_rows. Duplicates (rows identical to an earlier one) are counted in stats.duplicate_rows, and removed only with dedupe. The 100,000-row limit counts the rows kept, after deduplication.
  • JSON is an array of objects (or a single object), NDJSON (.ndjson, .jsonl) one object per line. Columns are every key found, in order of appearance; nested values are kept as JSON text, and items that are not objects are skipped.
  • Type. Dataflow reads the file's bytes, not only its name. A spreadsheet whose extension does not match its content is refused. An .xls may also be the HTML or XML table some tools export under that name. A zipped spreadsheet (XLSX, ODS, Numbers) may hold up to 512 MB and 10,000 parts once unzipped, measured on what it really holds. An HTML or XML file, or a binary .xls, is read up to 20 MB: save a bigger one as XLSX or CSV.
  • Size of values. A file has at most 1,000 columns. A value, or a column name, holds at most 32,767 characters (a spreadsheet cell's own limit), and a row at most 262,144 in all. A file over these limits is refused, and the error gives the row (as the file numbers it, from 1) and the column: error.details.row and error.details.column.
  • One file at a time. Your workspace reads one file at a time, whether you upload it, parse it again or preview a URL. Another meanwhile answers 429 parse_busy: send it again when the first is read. A file that takes more than 60 s, or too much memory, to read is refused with input_unsafe.
  • Encoding. Text files are decoded from their byte order mark (UTF-8, UTF-16) if they have one, else as UTF-8, else as Windows-1252. Save in UTF-8 when in doubt.
  • Separator. CSV, TSV and TXT files may use commas, semicolons, tabs or pipes: a first line sep=; names it, otherwise Dataflow picks the one that splits the first rows evenly. Values in double quotes may hold separators, quotes (doubled: "") and line breaks.
  • Row problems. A text row with fewer fields than the header (TooFewFields), more fields holding a value (TooManyFields), a quote never closed (MissingQuotes) or a value going on after its closing quote (InvalidQuotes) is still read, and reported in stats.row_error_count and stats.row_errors (the first 100, such as {"row": 12, "code": "TooFewFields", "message": "3 fields expected, 2 found"}; row is the row number in the file, from 1, blank rows included). A quote never closed takes the rest of the file into one value: check the row count.

Read a file again

POST /v1/inputs/{id}/parse reads an uploaded file again with other options: another sheet, header line or deduplication. The body is optional (no body: the defaults) and the answer is the same summary as an upload, with 200. Projects that use the input get the new rows at their next run; their mapping is not checked again. A mapped column that is gone leaves its parameter empty: rows then missing a required parameter are skipped as invalid. A list cannot be parsed again (409 input_no_file).

curl https://dataflow.piloterr.com/v1/inputs/4f1c2a9e-…/parse \
  -H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
  -d '{"sheet": "Archive", "header": 1}'

Big files

Send big files straight to the storage instead of through the API. The URL only accepts exactly size bytes, for 15 minutes.

SIZE=$(wc -c < big.xlsx | tr -d ' ')
UP=$(curl -s https://dataflow.piloterr.com/v1/inputs/uploads \
  -H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
  -d "{\"filename\": \"big.xlsx\", \"size\": $SIZE}")

# 1. Send the file to the presigned URL (no API key: the URL is signed).
curl -X PUT --data-binary @big.xlsx "$(echo "$UP" | jq -r .upload_url)"

# 2. Parse it. Same options as an upload.
curl https://dataflow.piloterr.com/v1/inputs/$(echo "$UP" | jq -r .id)/parse \
  -H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
  -d '{"sheet": "Leads", "header": 1, "dedupe": true}'

The answer to /uploads (201) holds the input's id, the upload_url, the method (PUT), the headers to send with it (Content-Length) and expires_in in seconds (900). A size over 50 MB is refused at once (413 input_too_large). Until the file is there, /parse answers 409 input_not_uploaded.

On this page