ankane/ruby-polars

Request: add support for `df.write_json(nil)`, which returns the JSON as a string

DeflateAwning opened this issue · 7 comments

df.write_json(None) is supported in Python, and can be used to return the dataframe as a JSON string right away (instead of writing to a file and then reading the file). It would be awesome if support for that was added here!

Hi @DeflateAwning, added in the commit above.

Wow, thanks a lot! Very impressive implementation speed! Looking forward to trying it out in the next release!

Would you mind tagging a new release with this change in it?

Any chance we can have that for all the .write_ calls? That would be amazing!
parquet for example? Currently I have to write it to temp file and read it afterwards, feels hackish.

A new issue is probably best for tracking.

Just note that binary formats (e.g., parquet) don't support this behaviour in the core Rust/Python library (except via using the import io lib to act as a fake file-like object), so there's probably a low chance it'll be supported here.

@Antti Added support for writing to StringIO in the commit above.

io = StringIO.new
df.write_parquet(io)
p io.string

@DeflateAwning I don't plan to make a new release for this.

Great! Thank you! @ankane