vstinner / hachoir

Hachoir is a Python library to view and edit a binary stream field by field
http://hachoir.readthedocs.io/
GNU General Public License v2.0
599 stars 70 forks source link

[Feature Request / Enhancement] hachoir-metadata CSV or JSON output to external file #11

Open ivbeg opened 7 years ago

ivbeg commented 7 years ago

When I process multiple files it often require command-line tools to create CSV/JSON pipeline. Right now hachoir-metadata tool can't be used to create CSV or JSON. It will be very helpful if hachoir-metadata and other cmd tools will produce machine readable results.

vstinner commented 7 years ago

I like the idea. Would you like to implement it? I would prefer to avoid code duplication.

ivbeg commented 7 years ago

I love to code just right now busy with other projects till next month. But I could donate and support this feature via https://www.bountysource.com/ for example. I think it's really useful

vstinner commented 7 years ago

I'm not interested by bounties, but maybe @nneonneo is?

nneonneo commented 7 years ago

Sure thing, I could take a bounty. I'm also really busy with work, but it could be a nice feature to work on.

nneonneo commented 7 years ago

Before I get too far into any of this: have you looked at hachoir.metadata.csv? This is exposed by the hachoir-metadata-csv script (which isn't installed by setup.py, but is in the repository).

nosmokingbandit commented 7 years ago

@ivbeg I unofficially created something like this a while ago for the python2 version of Hachior and just today converted it to python 3.

Look at this pull request https://github.com/haypo/hachoir3/pull/16

I was unaware of this issue when I submitted the PR, but I believe this would do what you want. I'm thinking about moving one of my projects to python 3, but it relies on the dictionary output I made for the python2 version. This is a quick and dirty conversion but I haven't gotten it to choke on anything yet.

Its trivial to json.dump() this output to a file.

I was looking through the issues to see if there is anything I need to know about before I convert my project to python 3 and I was somewhat amused when I saw this issue.