Is it possible to "flatten" structured data (like JSON?) #1605
Replies: 2 comments 5 replies
-
Hi @marcopaganini! There are two popular options. One is to use The other option is to use I hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Hi @anjakefala I tried something similar (didn't know that 0 as levels meant everything). This almost creates the ideal situation, but it repeats each field in the array as headers, instead of copying those over as multiple records. Basically, the headers become x[0], x[1], etc... Is there a way around it? |
Beta Was this translation helpful? Give feedback.
-
I spend a lot of time analyzing structured data exported as JSON files. One example would be something like this:
Naturally, we can have multiple countries, each country can have multiple states, and each state can have multiple geographical information data attached to it.
When I try to open this file in visidata, I just get a "country" header followed by [1] (indicating one element in the array). I can drill down on these by hitting [Enter] but it's rather painful. z[Enter] produces slightly better results, but only allows me to see one element of the array at a time. I tried multiple combinations of Unfurl and Transpose, but nothing generates something that is easy to work with.
I'm looking for a way to somehow "flatten" these results. Essentially, produce something similar to a csv, formatted as something like:
For each of the records.
Is that possible in visidata? If not what's the recommended way to deal with these situations?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions