Generate Memory Report as valid CSV#97
Generate Memory Report as valid CSV#97joshuaflanagan wants to merge 3 commits intosripathikrishnan:masterfrom
Conversation
When a redis key contains a comma or quote, the output generated by the memory report is no longer parsable as a CSV.
The csv module will make sure all values are properly escaped so that the resulting file can be parsed by other applications.
The csv module in Python only works with text streams. Adapt the provided binary stream to look like a text stream .
|
I've updated the PR to add python 3 compatibility, fixing the build. |
|
@joshuaflanagan great catch! It's an important corner that have never been addressed. Small concern about your fix though, previous code used latin-1 encoding to keep byte values as is, your valid CSV solution use UTF-8. It will support Unicode characters but will change binary key names. Library user have a way to control desired byte/text manipulation by setting the string escape parameter. Can you please address this issue in this PR? |
The current memory report does not emit valid CSV if a Redis key contains a comma or quotes.
These are perfectly valid characters in a Redis key:
The current code makes no attempt to escape these characters, so the generated file is impossible to parse from any other application if one of these characters exist in the rdb.
Use the standard library CSV module to ensure valid CSV is always generated.