Transpose Table: swap rows and columns of CSV avatar

Transpose Table: swap rows and columns of CSV

Pricing

from $0.14 / 1,000 output rows

Go to Apify Store
Transpose Table: swap rows and columns of CSV

Transpose Table: swap rows and columns of CSV

Swaps the rows and columns of a table: Apify dataset, CSV or JSON file, or pasted CSV text. Pick a column to become the new headers. Works from the Console form. 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

3 days ago

Last modified

Features

Limited permissions

Share

Swap the rows and columns of a table

Returns your table turned on its side: every column becomes a row and every row becomes a column. For anyone who has a CSV, a JSON list or an Apify dataset laid out the wrong way round for the next step: a report with months down the side that a chart wants across the top, a scraper result with one product per row that you want to compare side by side, a spreadsheet export that a form or a database import expects the other way. Pick the column whose values should become the new headers, press Start, and download the result as CSV, JSON or Excel from the dataset. 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). A transposed table has one output row per column of your input table, so a table with 12 columns costs $0.0024. The $5 monthly free credit covers about 25,000 output rows. Failed runs, runs with no output rows and the demo are free. No scraping, no API keys.

Sample

Input (a dataset, a CSV file or pasted text), Header column: region

regionjanfebmar
North120135150
South809095
West607266

Output (first column named month with Name of the first output column):

monthNorthSouthWest
jan1208060
feb1359072
mar1509566

Without a header column the new columns are called row_1, row_2, ... and the region column stays in the result as a row of its own.

What it does

  • Transposes a table: the old column names go into the first column of the result (named field unless you choose another name), the old rows become columns.
  • Header column: the values of the column you name become the new column names, and that column is not repeated as a row. Empty or repeated values get safe names (row_3, a_2).
  • Three kinds of input: Apify datasets (resource picker, read permission only), public CSV / TSV / JSON / NDJSON file URLs, and a table pasted as text. Mix them in one run: each table is transposed on its own and, with more than one table, every row has a _source column.
  • File details handled for you: encoding (UTF-8, Shift JIS, Windows-1252), delimiter (comma, semicolon, tab, pipe) and numbers are detected. A JSON object that wraps the rows needs a Records path such as products. CSV without a header line works with First row is a header turned off.
  • Nested data: nested objects become dotted columns (owner.name; choose the separator). Arrays stay arrays.
  • Missing values become null, so rows with different fields still line up.
  • Safe by default: Max input rows (default 1,000, maximum 10,000) bounds the width of the result; when it cuts your table, inputTruncated is true in the run summary.

Input example

{
"fileUrls": ["https://dummyjson.com/products?limit=10&select=title,price,rating,stock"],
"recordsPath": "products",
"headerColumn": "title",
"firstColumnName": "measure"
}

Pasted text: {"csvText": "metric,q1,q2\nrevenue,120,135\ncosts,90,95", "headerColumn": "metric", "firstColumnName": "quarter"}. A dataset: {"datasetIds": ["<id>"], "headerColumn": "region"}.

Output

  • Dataset: the transposed rows, one per column of the input table. Download as CSV, JSON, Excel and more from the Console.
  • STATS record (key-value store): inputRows, outputRows, inputTruncated, chargedRows, one entry per table in tables (source, input rows, output rows, new columns) and per-source errors.

Rules worth knowing

  • Rows become columns, so a table with many rows gives a very wide result. Only the first Max input rows rows are read.
  • Transposing twice with the right header column gives back the original table (set Header column to field the second time).
  • Values keep their type: numbers stay numbers, empty cells stay null. In pasted or downloaded CSV text, numbers are recognized, but values with a leading zero (007) or more than 15 digits stay text.
  • Header values are turned into text for the new column names (1.0 becomes 1).
  • The first column is named field. If one of your header values is also field, it becomes field_2.

Limits (cannot be raised by input)

  • 20 tables per run; 50 MB per file; 10,000 input rows and 100,000 output rows per table
  • 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 or produces no rows. Set a maximum charge per run: the Actor then stops producing rows at that budget (never past it) and says so in truncated. On the Apify Free plan, the $5 of monthly platform credit covers about 25,000 rows a month.

Use cases

  • Months, quarters or years down the side to across the top (or back) for charts and slides
  • One product, listing or company per column for a side-by-side comparison
  • Flipping a key/value export so each record is a column, or each column a record
  • Preparing a CSV for a tool that expects the other orientation

FAQ

Does it change my source dataset? No. It only reads it and writes a new dataset. Why are some cells empty? The source rows did not all have the same fields. Missing values are null. My JSON file is an object, not an array. Give Records path (for example data.items). Without it, the only array of objects in the file is used. Can I use a column with repeated values as the header? Yes. Repeats get a _2, _3 suffix so no column is lost. What happens to the first column of my table when I leave Header column empty? It is kept: it becomes the first row of the result, with its old column name in the first column.

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

More tools from the same developer

  • Dataset Explode & Unpivot — explode array fields into rows, unpivot wide columns into name/value rows, or pivot back
  • CSV to Excel Converter — convert CSV, TSV, Excel XLSX, JSON and NDJSON files or Apify datasets into each other
  • Dataset Transform — flatten, filter, rename and convert any Apify dataset, export CSV / JSON / JSONL with a link
  • JSON to CSV Converter — turn nested JSON files or datasets into one flat CSV file
  • Flatten JSON to CSV — flatten nested JSON into flat rows with the separator you choose