Skip to content

Parser.py

Dylan Rodriquez edited this page Jun 20, 2017 · 3 revisions

Initialization:

The Parser module contains one class, Table(), initialized with the filepath of the JSON and contains two instance variables:

Table.filepath = The filepath of the JSON file

Table.parsedTable = The resulting parsed table

Methods:

Table() contains multiple methods to achieve the above:

Table.openJsonFile(self): Opens and reads the JSON file at Table.filepath.

Table.parseJson(self): Parses a JSON file to a pandas DataFrame

Table.createDataFrame(self): Creates a Pandas DataFrame from a dictionary

Table.parseDataColumn(self): Iterates over dictionaries in a Pandas DataFrame

Table.concatAndTransposeData(self): Formats all dictionaries present in columns to a pandas DataFrame

Table.parseNameSpace(self, regex, testString): takes a regex string and searches for matches.

Table.namespaceBruteSearch(self): Extracts all available column headers in the namespace column.

Table.getAllFrames(self): Creates a human readable DataFrame

Table.addFromBruteSearch(self): adds column headers from namespaces to each record

Table.renameCol(self): Creates an appropriate name for each column

Usage:

from Parser import Table
fpath = ~/documents/V2/someJsonFile.json
table = Table(fpath)
table.parsedTable()
  • V2
    • parser
    • jsonToCSV
    • findOmissions

Parsing JSON files

  • Usage
  • Output

Determining compliance to survey completion

  • Usage
  • Output
Clone this wiki locally