Nested JSON in CSV

I have a CSV file with 1500 rows of data. I am wanting to optimize how I have certain data and nest it in Elastic.

Here's an example:

Name, Location, Age, Favorite Colors
Bob, USA, 32, Orange, Pink
Jane, USA, 28, Green, Pink

Currently "Orange, Pink" and "Green, Pink" will be displayed as two documents. If I visualize this data, it will show as "Orange, Pink" and "Green, Pink" when what I would want to see is Orange, Green, and two counts of Pink.

I want to Nest this data so that it looks more like:
Name, Location, Age, Favorite Colors
Bob, USA, 32, Orange
........................ Pink

I'm having trouble finding the right documentation for how to write this into a CSV. I've read you can put JSON nesting into a cell in a CSV but I can't seem to figure out how it's formatting. I'm getting conflicting info that it needs to be a true array or if it can be a single line.

When I try to import nested data with nested mapping, no data imports at all, even for the columns that just have keywords like "Bob."


The CSV format does not have a concept of arrays so you won't be able to do what you want using only CSV. Thinking out loud, here are ways to fix your problem:

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.