Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: dataframe download separator#8318

Merged
mscolnick merged 3 commits intomarimo-team:mainfrom
vavavavavavavavava:feat/dataframe-download-separator
Mar 2, 2026
Merged

feat: dataframe download separator#8318
mscolnick merged 3 commits intomarimo-team:mainfrom
vavavavavavavavava:feat/dataframe-download-separator

Conversation

Copy link
Contributor

vavavavavavavavava commented Feb 14, 2026

Summary

Add configurable CSV separator support to dataframe downloads, with consistent behavior across table backends.
Closes #7353

Description of Changes

This PR adds download_csv_separator to mo.ui.dataframe(...) and threads it through the full CSV download path so user-provided separators are respected end-to-end.

What changed

  • Added new dataframe option:
    • download_csv_separator: str | None = None
  • Propagated separator through:
    • dataframe download handler
    • download_as(...)
    • TableManager.to_csv(...) / to_csv_str(...)
    • backend table managers (default / narwhals / pandas / polars)

Backend behavior

  • pandas: passes separator to DataFrame.to_csv(sep=...)
  • polars: passes separator to write_csv(separator=...) (including fallback conversion path)
  • narwhals utility:
    • keeps native write_csv() for default comma
    • uses Python csv.writer for non-comma separators to avoid backend-specific inconsistency
  • default table manager: forwards separator to delegated manager

Why

write_csv(separator=...) is not consistently reliable across all narwhals-backed dataframe combinations.
This change makes non-comma CSV output predictable while preserving existing default behavior.

Backward compatibility

  • Default behavior is unchanged (comma-separated CSV).
  • Existing callers continue to work without modification.
  • New behavior is opt-in via download_csv_separator.

Example

import marimo as mo
import pandas as pd

df = pd.DataFrame({"name": ["Alice", "Bob"], "value": [1, 2]})

# Before: default download behavior
mo.ui.dataframe(df, show_download=True)

# After: configurable CSV encoding / separator and JSON escaping
mo.ui.dataframe(
df,
show_download=True,
download_csv_separator=";",
)

Tests

Added/updated tests for:

  • dataframe CSV download with custom separator
  • dataframe_to_csv(..., separator=";") behavior across dataframe backends

Checklist

Copy link

vercel bot commented Feb 14, 2026 *
edited
Loading

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Preview, Comment Feb 14, 2026 2:47pm

vercel bot deployed to Preview February 14, 2026 14:47 View deployment
akshayka requested review from akshayka and dmadisetti February 19, 2026 18:59
dmadisetti reviewed Feb 19, 2026
download_csv_encoding (str | None, optional): Encoding used when downloading CSV.
Defaults to the runtime config value (or "utf-8" if not configured).
Set to "utf-8-sig" to include BOM for Excel.
download_csv_separator (str | None, optional): Separator used in CSV downloads.
Copy link
Collaborator

dmadisetti Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on just "download_separator" ?

Copy link
Contributor Author

vavavavavavavavava Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose download_csv_separator for consistency with download_csv_encoding. Since both options are specific to CSV downloads, I thought keeping the csv prefix makes the API clearer

Copy link
Contributor Author

vavavavavavavavava Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dmadisetti

Just wanted to gently follow up on this -- happy to rename it to download_separator if you think that's preferable.

Let me know what you'd like, and I'll update the PR accordingly. Thanks!

dmadisetti reacted with thumbs up emoji
Copy link
Contributor

mscolnick Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vavavavavavavavava im happy with download_csv_separator but i will make sure we get everyones sign-off

mscolnick added api-change enhancement New feature or request labels Feb 22, 2026
mscolnick requested a review from dmadisetti March 2, 2026 14:54
dmadisetti approved these changes Mar 2, 2026
Copy link
Collaborator

dmadisetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern was download_csv_separator == "download comma separated value separator"

But I do think this is fine for consistency!

mscolnick merged commit 35e0c85 into marimo-team:main Mar 2, 2026
40 of 43 checks passed
Copy link

github-actions bot commented Mar 2, 2026

Development release published. You may be able to view the changes at https://marimo.app?v=0.20.3-dev82

Copy link
Contributor Author

vavavavavavavavava commented Mar 3, 2026

@dmadisetti
@mscolnick

Thanks for the review and merge -- much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

mscolnick mscolnick left review comments

dmadisetti dmadisetti approved these changes

akshayka Awaiting requested review from akshayka

Assignees

No one assigned

Labels

api-change enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Feature request: Allow configuring encoding for mo.ui.dataframe() download button

3 participants