def load_wikisql_tables(filepath):
  """Loads the WikiSQL tables from a path and reformats as the format."""
  dbs = dict()
  with gfile.Open(filepath) as infile:
    tables = [json.loads(line) for line in infile if line]

  for table in tables:
    db_dict = dict()
    table_name = table['section_title'] if 'section_title' in table and table[
        'section_title'] else (
            table['name'] if 'name' in table else table['page_title'])

    table_name = normalize_entities(table_name)

    db_dict[table_name] = list()
    for column_name, column_type in zip(table['header'], table['types']):
      if column_type == 'real':
        column_type = 'number'
      assert column_type in {'text', 'number'}, column_type
      column_name = normalize_entities(column_name)

      db_dict[table_name].append({
          'field name': column_name,
          'is primary key': False,
          'is foreign key': False,
          'type': column_type
      })
    if table['id'] not in dbs:
      dbs[table['id']] = db_dict

  return dbs
Loads the WikiSQL tables from a path and reformats as the format.
language/xsp/data_preprocessing/wikisql_preprocessing.py