-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add gzip
for to_json
#3492
Add gzip
for to_json
#3492
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice thank you !
import gzip | ||
|
||
|
||
class IOHandler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a naming suggestion, feel free to ignore if IOHandler
sounds better to you
class IOHandler: | |
class open_compressed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think this could simply be a function that returns the output of open
or gzip.open
, what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this but I think we'll need to close file too after writing which we aren't doing in json.py
hence __exit__
thing in context manager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IOHandler
is not just opening compressed files but uncompressed as well :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bhavitvyamalik!!! :)
Yes, indeed one of the advantages of handling directly the compression
parameter ourselves, is that we can use it for other formats, like CSV or text (and maybe other future supported formats).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good ! Thanks a lot @bhavitvyamalik :)
(Partially) closes #3480. I have added
gzip
compression forto_json
. I realised we can run into this compression problem withto_csv
as well.IOHandler
can be used forto_csv
too. Please let me know if any changes are required.