Skip to content

Parser.mergeToHeader

Latest
Compare
Choose a tag to compare
@klm127 klm127 released this 25 Jul 19:20

Added an important function for dealing with data that has parent descriptors across multiple rows or columns. Parser.mergeToHeader(index)

Example data:

Country Industry Tax Revenue
USA Manufacturing 150
France Manufacturing 150
USA Service 300
USA Auto Repair 100

In this case the header would be set to COL with Parser.setHeader('COL') so that the top level objects in the JSON would be the country names.

What the new function does is take a specified column and create an array out of that and the header column, so that nesting can work.

The nesting functionality already existed, but it was designed based on data that had already merged column headers.

Desired output:

{
 "USA": {
    "Manufacturing": {
        "Tax Revenue": 150
    },
    "Service": {
        "Tax Revenue": 300
    }
    "Auto Repair": {
        "Tax Revenue": 100
    }
  }
 "France": {
   "Manufacturing": {
      "Tax Revenue": 150
    }
  }  
}