Hacker News new | ask | show | jobs
by hermitcrab 1935 days ago
If you mean convert between data formats (e.g. between, CSV,YAML,JSON, XML) there are programs already that can do that. For example our Easy Data Transform. However there are wrinkles because some of these formats are trees and some are tables. Flattening a tree into a table isn't too hard. But unflattening a table back into the same tree as the original is trickier. Has anyone got any good references on that?
1 comments

do you have a list for that? i am aware, that there are dialects and {table,trees,graphs}<->{table,trees,graphs} may be a problem for some languages, but having it at least would be a progress.
Do you mean a link? If so: https://www.easydatatransform.com/

Just as an example of the tree<->table issue:

If you input this JSON tree:

{ "Color": "Blue", "Part": [ { "Type": "A", "Number": [ "1", "2" ] }, { "Type": "B", "Number": [ "1" ] } ]

It can be converted to a table as:

Color,Part.Type,Part.Number

Blue,A,1

Blue,A,2

Blue,B,1

Which is fine is you then want to output as Excel, CSV etc. But if you then output that back to JSON you get:

[ { "Color": "Blue", "Part": { "Type": "A", "Number": "1" } }, { "Color": "Blue", "Part": { "Type": "A", "Number": "2" } }, { "Color": "Blue", "Part": { "Type": "B", "Number": "1" } } ]

Which is conceptually equivalent, but less compact (similarly for XML). I am hoping to fix this issue. But if anyone has any links to how to unflatten a table into a compact tree, I'm all ears.

i meant a cli tool :D but thanks
You can also run it from the command line.