-
-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better way of representing binary data in .csv output #1034
Comments
Most obvious option is base64. Any other potential solutions I'm missing? |
The datasette-render-binary plugin does this, which I really like - but without the different coloured fonts I'm not sure how readable it would be as just plain text: Really the goal here is to find the most human-friendly option, so that people looking at the output have a vague idea what's going on. That's why I'm not leaping at the chance to use base64. |
Asked for ideas on Twitter: https://twitter.com/simonw/status/1318409558805467136 |
I could go with the same format as
Problem with this is that it's ambiguous: if the ASCII characters But since representing binary data in CSV fundamentally doesn't make sense I'm not sure if that really matters. |
An even easier option: do what the Datasette UI does and output |
Or... default to |
|
This feels good to me - it's consistent with how other features in Datasette work, and it means users who need the binary data in CSV (for whatever reason) can get it if they want to. |
Enzo has a great solution here: https://twitter.com/enzo_mdd/status/1318685442976436226
In #1036 I'm planning on adding a way for users to access BLOB data. I can include that URL in the CSV output. |
Blocked awaiting #1036 (update: now unblocked) |
This is actually a bit tricky to implement, for a few reasons:
|
Here's how those absolute datasette/datasette/views/table.py Lines 774 to 776 in 5db7ae3
|
I should turn |
That documentation: https://docs.datasette.io/en/latest/internals.html#absolute-url-request-path |
What should happen for CSV export of arbitrary SQL queries, where there's no obvious BLOB to link to? |
For arbitrary CSV the only solution I can think of is to embed the base64 value. |
SQLite actually has APIs that could help here: https://www.sqlite.org/c3ref/column_database_name.html - for any given SQL query they identify the origin/table/column that is the source of each resulting column. Those aren't exposed in the Python |
I'm going to link to. the new |
Demos: https://latest.datasette.io/fixtures/binary_data.csv?_size=max
|
I just noticed this: https://latest.datasette.io/fixtures/binary_data.csv
There's no good way to represent binary data in a CSV file, but this seems like one of the more-bad options.
The text was updated successfully, but these errors were encountered: