evidens / json2csv

Converts JSON files to CSV (pulling data from nested structures). Useful for Mongo data
MIT License
264 stars 97 forks source link

Automatically generate outlines #6

Closed leifp closed 9 years ago

leifp commented 9 years ago

This PR is just for comments. Assuming you like the idea / interface / impl, I can add tests.

evidens commented 9 years ago

This is a great addition. One or two comments about style but with a few tests I'd be happy to merge this in

leifp commented 9 years ago

OK, I'll make that change and write a couple tests. You may see the author change, since I was mistakenly using my work email.

leifp commented 9 years ago

OK, PR updated. One change I made to support my use case is to handle arrays of different lengths. You should decide whether this behavior will break existing usage. The previous behavior was

  1. Throw an IndexError if the data array was shorter than the outline spec
  2. Silently ignore elements if the data array was longer than the outline spec

I changed the behavior of case 1 to return None; case 2 remains the same.

Also, I have not tested with Python 3.

evidens commented 9 years ago

I think you're correct with the IndexError not making sense. I never really used that functionality so your additions make sense.

Thanks for the contributions and tests. I haven't tested this on Python 3 either. For now it's fine, if someone requests it, I'll look into the issues that might arise.