Dataset Type Caster: fix CSV & JSON column types avatar

Dataset Type Caster: fix CSV & JSON column types

Pricing

from $0.14 / 1,000 output rows

Go to Apify Store
Dataset Type Caster: fix CSV & JSON column types

Dataset Type Caster: fix CSV & JSON column types

Turns text columns of a CSV / JSON file or Apify dataset into integers, numbers, booleans, ISO dates, trimmed text or null. Reads 1,200 / 1.234,50 / ¥ / full-width digits and Japanese era dates (R5.4.1). Bad cells are listed per row. Empty input = free demo.

Pricing

from $0.14 / 1,000 output rows

Rating

0.0

(0)

Developer

Actor Factory

Actor Factory

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

20 hours ago

Last modified

Features

Limited permissions

Share

Convert the column types of a CSV, JSON file or Apify dataset

Turns text into real numbers, booleans and dates, and tells you exactly which cells it could not read. For anyone whose data arrives as text: a scraper dataset where every price is "¥1,200" or "1.234,50", a CSV export with yes/no and はい/いいえ, order dates written R5.4.1, 2024年4月1日 or 13/04/2024, N/A and - where a value is missing. Name the columns and their types, press Start, and download the converted rows as CSV, JSON or Excel from the dataset (or as one CSV file). It works from the Console form: no code, no spreadsheet formulas.

Try it free: leave all inputs empty and press Start (the demo is not charged and its rows carry _demo: true). $0.20 per 1,000 output rows, charged per row ($0.0002 a row). Converting 5,000 rows costs $1.00. The $5 monthly free credit covers about 25,000 output rows. Reading rows is free. Rows left out because of a bad cell (when you choose that) are not charged. Failed runs and the demo are free. No scraping, no API keys.

Sample

Input rows (a dataset or a CSV file), Casts: [{"column": "price", "type": "number"}, {"column": "qty", "type": "integer"}, {"column": "paid", "type": "boolean"}, {"column": "ordered", "type": "date"}]

priceqtypaidordered
¥1,2003はいR5.4.1
1.234,5012no2024年4月2日
(45.00)2 pcsmaybe03/04/2024

Output (with the default Keep the original value for unreadable cells):

priceqtypaidordered_castErrors
12003true2023-04-01
1234.512false2024-04-02
-452 pcsmaybe03/04/2024["qty", "paid", "ordered"]

2 pcs is not a whole number, maybe is not a yes/no word, and 03/04/2024 could be 3 April or 4 March, so those three cells stay as they were and their column names are listed in _castErrors. Rows without a problem have no _castErrors.

What it does

  • integer: whole numbers. Understands 1,200, 1.234.567, 1 200, ¥1,200, $5, 5円, USD 5, (45) and ▲45 (negative), 45-, and full-width digits such as 123. A value with decimals (12.5) is an error unless you set the option fraction to round, floor, ceil or trunc.
  • number: the same, with decimals. The decimal separator is read as . or , automatically (1,234.50, 1.234,50 and 12,5 all work); set the option decimal to . or , when you know it. 1,200 is read as 1200 and 1.200 as 1.2 unless you set decimal. Percent values (12%) are an error unless the option percent is divide (0.12) or strip (12).
  • boolean: true/false, yes/no, y/n, t/f, on/off, 1/0, はい/いいえ, 真/偽, ○/×, any case. Give your own words with the options trueValues and falseValues (they replace the defaults).
  • date: written out as ISO 8601. Reads 2024-04-01, 2024/4/1, 2024.04.01, 20240401, 4 Mar 2026, March 4, 2026, 2024-04-01T10:00:00Z, Japanese dates such as 2024年4月1日, and Japanese era dates such as R5.4.1, 令和5年4月1日, H31.4.30, 令和元年5月1日 (Meiji, Taisho, Showa, Heisei and Reiwa; a date outside its era, such as H31.5.1, is an error). Dates like 03/04/2024 are read only when it is clear which part is the day (13/04/2024) or when you set dateOrder to dmy or mdy; otherwise they are an error rather than a guess. Dates with dots (04.03.2026) are day first. Two-digit years: 00-69 mean 2000-2069, 70-99 mean 1970-1999. Set inputFormats to your own strptime patterns (for example ["%d/%m/%Y", "auto"]), and outputFormat to iso (the default, 2024-04-01), iso-datetime or any strftime pattern such as %d/%m/%Y. A time of day in the input is dropped unless the output format keeps it.
  • string: trim (on by default), upper/lower case, collapse repeated spaces, normalise full-width characters to half-width. Numbers become text (5 becomes "5").
  • null: the strings you list become real null (default list: empty, N/A, NA, null, none, nan, -, --, —; any case). Other values stay as they are.
  • Empty cells (empty text, only spaces, or already null) become null for integer, number, boolean and date, and are not counted as errors.
  • Several casts for one column apply in the order given: first make N/A null, then cast the column to number.
  • Two kinds of input: Apify datasets (resource picker, read permission only) and public CSV / TSV / JSON / NDJSON file URLs, mixed freely. Encoding (UTF-8, Shift JIS, Windows-1252) and delimiter (comma, semicolon, tab, pipe) are detected. Columns you do not list come out unchanged.

Input example

{
"fileUrls": ["https://raw.githubusercontent.com/mwaskom/seaborn-data/master/titanic.csv"],
"casts": [
{"column": "survived", "type": "boolean"},
{"column": "age", "type": "integer", "options": {"fraction": "round"}},
{"column": "fare", "type": "number"}
],
"onError": "keep"
}

Short form: "casts": ["price:number", "paid:boolean", "ordered:date"].

Output

  • Dataset: one row per input row, in the input order, with the cast columns. Download as CSV, JSON, Excel and more from the Console.
  • _castErrors: on every row that had an unreadable cell, the list of the column names that failed.
  • cast.csv (key-value store, only with Also save a CSV file).
  • FAILED_ROWS (key-value store, only with Leave the whole row out when a row failed): the first 1,000 left-out rows with the reason per cell.
  • STATS record (key-value store): inputRows, outputRows, chargedRows, rowsWithErrors, cellErrors, rows read per source, per column how many cells were cast, emptied and failed, and up to 20 examples of unreadable values with the row number and the reason.

If a cell cannot be read

Choose If a cell cannot be read:

  • Keep the original value (default): the cell stays as it was, the column name goes into _castErrors.
  • Set the cell to null: the cell becomes null, the column name goes into _castErrors.
  • Leave the whole row out: the row is not written and not charged. The first 1,000 such rows are saved in FAILED_ROWS with the reason.

Limits (cannot be raised by input)

  • Up to 200,000 input rows per run. If there are more rows than Max input rows, the run stops without converting or charging rather than giving you a half-converted table. Split the data first.
  • 20 datasets and files per run; 100 MB per file (a JSON array: 50 MB, because it has to be read whole; use NDJSON, one object per line, for bigger files); 50 casts.
  • Columns are top-level names (case-sensitive). Nested values cannot be cast, except to text as JSON for a CSV copy.
  • Whole numbers and numbers up to 9,007,199,254,740,991 (larger values are an error, because they would lose digits in JSON).
  • Source URLs must be public http or https links. Addresses on internal networks (localhost, private ranges, cloud metadata) are blocked, also after redirects. Excel files are not read (save them as CSV first).

Pricing

Pay per event: $0.20 per 1,000 output rows (event row, $0.0002 per output row). Reading input rows is free. Nothing is charged when the run fails, for the demo, or for rows left out. Set a maximum charge per run: the Actor then writes only the first rows that fit the budget (never past it) and says so in the run summary. If the budget is lower than the price of one row, the run stops at once without charging. On the Apify Free plan, the $5 of monthly platform credit covers about 25,000 rows a month.

Use cases

  • Make scraped prices, ratings and counts into numbers before sorting, filtering or charting them
  • Clean a CSV export before an import: yes/no to true/false, N/A to empty, dates to ISO 8601
  • Read Japanese business files: era dates, full-width digits, 円, ▲ negatives
  • Find the bad cells: with the default setting, filter on _castErrors to see what needs a human
  • Prepare typed, consistent columns for the next Actor in a workflow

FAQ

Does it change my source dataset? No. It only reads it and writes a new dataset. Why is a cell unchanged? It could not be read as the chosen type. Look for _castErrors on the row, and the examples in the run summary. Why did 1.200 become 1.2? A single dot is read as a decimal point. Set the option decimal to , if your numbers use dots for thousands. Why is 03/04/2024 an error? It could be 3 April or 4 March. Set dateOrder to dmy or mdy and it is read. Do I get 1200 or 1200.0? Whole values come out as whole numbers (1200), others with decimals (1234.5). Can I rename a column or change a column and keep the old one? No. The cast replaces the value in the same column.

If this Actor saved you time, a rating on the Store helps others find it.

More tools from the same developer

  • Filter CSV, JSON or Dataset Rows by Condition — keep only the rows of a CSV, JSON file or dataset that match simple conditions like country = US or price > 100
  • Dataset Sort — sort a CSV, JSON file or dataset by one or more columns: numbers, text or dates, natural order, top-N and dedupe
  • CSV to JSON Converter — turn CSV files into typed JSON: encoding and delimiter detected, numbers and booleans typed, dotted headers nested, array, NDJSON or keyed output
  • Merge Datasets — combine several datasets or CSV/JSON files into one, with columns aligned
  • CSV Encoding Converter — detect the encoding of CSV and text files and convert them to UTF-8 (or another encoding)