saulpw / visidata

A terminal spreadsheet multitool for discovering and arranging data
http://visidata.org
GNU General Public License v3.0
7.62k stars 274 forks source link

[feature request] msgpack and msgpackz loaders #2419

Open maxim-uvarov opened 3 weeks ago

maxim-uvarov commented 3 weeks ago

Saul, Anja, could you please add support for the msgpack and msgpackz formats? I would love to replace JSON (which works fine anyway) with msgpack for communication between nushell and visidata. I tried to rewrite the current JSON loader for msgpack with the help of GPT, but my attempts failed. So I'm asking you, as it doesn't seem like a very difficult task. 🙏🙏🙏

saulpw commented 3 weeks ago

@maxim-uvarov Can you provide a short Python script that uses an existing Python import (perhaps from PyPI) to parse msgpack into a Python dict/array? And a sample file to test it with.

maxim-uvarov commented 3 weeks ago

Saul, here are you are: msgpack-files.zip 🙏

Also, could you please help with allowing the opening of those binary formats received from stdin?

files in archive:

msgpackz_loader1.py
msgpack_loader1.py
1.msgpackz
1.msgpack
> python3 msgpack_loader1.py
[{'name': '1.msgpack', 'type': 'file', 'size': 249, 'modified': Timestamp(seconds=1717917699, nanoseconds=885072844)}, {'name': '1.msgpackz', 'type': 'file', 'size': 5981, 'modified': Timestamp(seconds=1717328654, nanoseconds=6337105)}]
> python3 msgpackz_loader1.py
[{'name': '1.msgpack', 'type': 'file', 'size': 247, 'modified': Timestamp(seconds=1717917709, nanoseconds=189066405)}, {'name': '1.msgpack.zip', 'type': 'file', 'size': 275, 'modified': Timestamp(seconds=1717917832, nanoseconds=368912550)}, {'name': '1.msgpackz', 'type': 'file', 'size': 5981, 'modified': Timestamp(seconds=1717328654, nanoseconds=6337105)}, {'name': 'msgpack_loader1.py', 'type': 'file', 'size': 332, 'modified': Timestamp(seconds=1717917728, nanoseconds=220876256)}, {'name': 'msgpack_test.py', 'type': 'file', 'size': 1795, 'modified': Timestamp(seconds=1717562304, nanoseconds=101682224)}]
saulpw commented 3 weeks ago

The loader was trivial; see the referenced PR. GPT is useless for this apparently.

We can merge it once the PR is updated to address all the items in the loader checklist. If you're up to the task, @maxim-uvarov, it would be much appreciated.

maxim-uvarov commented 3 weeks ago

Thank you so much @saulpw!!! Yep, I will try to work on the PR to finish it properly