Skip to the converter
Pandas to CSV

About

About this tool

Pandas to CSV Converter does one job: it turns tabular data or apd.DataFrame(...) literal into a CSV file, and gives you thedf.to_csv() call that produces the same file in your own script. It is an independent developer tool, not affiliated with the pandas project.

Why it exists

Exporting a DataFrame looks like a one-liner until the file lands somewhere else. The index turns up as an unnamed first column. Excel mangles accented characters. A colleague's import breaks on a semicolon. Each of those problems is one argument into_csv(), and the fastest way to find that argument is to see the file before you commit to it.

So the tool shows all three things at once: the data as parsed, the CSV as it will be written, and the exact call that reproduces it.

How it works

  1. Parsing. Delimited text is read with an RFC 4180-style reader that handles quoted fields, doubled quotes and CRLF, CR or LF line endings. The delimiter is detected by scoring comma, semicolon, tab and pipe against each other. Space-aligned columns — print(df) output — and single-column lists are detected too.
  2. DataFrame literals. A pd.DataFrame({…}) literal is read by a small tokenizer and parser written for this site. It understands dictionaries of columns, lists of rows with columns=, lists of records and index=, and it rejects everything else with a message that says so.
  3. Formatting. Values are rendered the way pandas renders them, including CPython's shortest-round-trip repr for floats and a strftime subset for dates.
  4. Writing. The formatted table is serialized with the quoting and line terminator you selected and encoded to the bytes of your chosen encoding. The preview and the downloaded file come from the same values, so they cannot disagree.

What it deliberately does not do

  • It never runs your Python. There is no eval, noFunction constructor, and no Python interpreter in the page. The literal parser recognizes a defined subset of DataFrame syntax and reports anything outside it. If the input cannot be parsed safely, you get a message instead of an attempt.
  • It does not upload anything. There is no conversion API to upload to. The whole pipeline runs in the tab.
  • It does not do everything. No JSON, Excel, Parquet or PDF exports, no CSV-to-DataFrame direction, no accounts and no dashboards. Those are different tools, and pretending otherwise would make this one worse.

How to check all of this

You do not have to take any of it on trust. Open your browser's network panel and paste something — you will see no request carrying your data. The generated snippet is plain text you can read before you paste it anywhere. And the behaviour being described is the documented behaviour of DataFrame.to_csv(), which is the reference this tool follows.

Contact

Corrections are welcome, especially if a generated call disagrees with pandas. Write to[email protected] — the contact pageexplains what to include.