Skip to content

Releases: klm127/census-csv-parser

Parser.mergeToHeader

25 Jul 19:20
Compare
Choose a tag to compare

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
    }
  }  
}

Parser Filter Operations

16 Jul 18:53
Compare
Choose a tag to compare

Added Parser.chop and Parser.chopColumn which encapsulate util.chop and util.chopColumn while also operating on Parser.rowHeaders and Parser.columnHeaders properly.

Added header search via passing string as 'find' parameter to Parser.chop and Parser.chopColumn to cause RegEx based column and row deletion searches to test (extracted) data header rows.