feat: dataframe download separator#8318
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| 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. |
There was a problem hiding this comment.
Thoughts on just "download_separator" ?
There was a problem hiding this comment.
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 🙂
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
@vavavavavavavavava im happy with download_csv_separator but i will make sure we get everyones sign-off
dmadisetti
left a comment
There was a problem hiding this comment.
My concern was download_csv_separator == "download comma separated value separator"
But I do think this is fine for consistency!
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.20.3-dev82 |
|
Thanks for the review and merge — much appreciated! |
📝 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_separatortomo.ui.dataframe(...)and threads it through the full CSV download path so user-provided separators are respected end-to-end.What changed
download_csv_separator: str | None = Nonedataframedownload handlerdownload_as(...)TableManager.to_csv(...)/to_csv_str(...)Backend behavior
DataFrame.to_csv(sep=...)write_csv(separator=...)(including fallback conversion path)write_csv()for default commacsv.writerfor non-comma separators to avoid backend-specific inconsistencyWhy
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
download_csv_separator.Example
Tests
Added/updated tests for:
dataframe_to_csv(..., separator=";")behavior across dataframe backends📋 Checklist
mo.ui.dataframe()download button #7353)