示例#1
0
 def to_csv(self):
     """Export table from json engine to CSV file"""
     for keys in list(self.script.tables):
         table_name = self.opts['table_name'].format(db=self.db_name, table=keys)
         header = self.script.tables[keys].get_insert_columns(join=False, create=True)
         csv_outfile = json2csv(table_name, header_values=header)
         sort_csv(csv_outfile)
示例#2
0
def test_json2csv():
    """Test json2csv function
    creates a json file and tests the md5 sum calculation"""
    json_file = create_file("""[ {"User": "******", "Country": "US", "Age": "25"} ]""", 'output.json')
    output_json = json2csv(json_file, "output_json.csv", header_values=["User", "Country", "Age"])
    obs_out = file_2string(output_json)
    os.remove(output_json)
    assert obs_out == 'User,Country,Age\nAlex,US,25\n'
示例#3
0
 def to_csv(self):
     """Export table from json engine to CSV file"""
     for keys in list(self.script.tables):
         table_name = self.opts['table_name'].format(db=self.db_name,
                                                     table=keys)
         header = self.script.tables[keys].get_insert_columns(join=False,
                                                              create=True)
         csv_outfile = json2csv(table_name, header_values=header)
         sort_csv(csv_outfile)
示例#4
0
def test_json2csv():
    """Test json2csv function
    creates a json file and tests the md5 sum calculation"""
    json_file = create_file(
        """[ {"User": "******", "Country": "US", "Age": "25"} ]""",
        'output.json')
    output_json = json2csv(json_file,
                           "test/output_json.csv",
                           header_values=["User", "Country", "Age"])
    obs_out = file_2string(output_json)
    assert obs_out == 'User,Country,Age\nAlex,US,25'
示例#5
0
def test_json2csv():
    """Test json2csv function.

    Creates a json file and tests the md5 sum calculation.
    """
    json_file = create_file(
        ["""[ {"User": "******", "Country": "US", "Age": "25"} ]"""],
        'output.json')

    output_json = json2csv(json_file,
                           "output_json.csv",
                           header_values=["User", "Country", "Age"])
    obs_out = file_2list(output_json)
    os.remove(output_json)
    assert obs_out == ['User,Country,Age', 'Alex,US,25']
示例#6
0
 def to_csv(self):
     """Export table from json engine to CSV file"""
     keys = [columnname[0] for columnname in self.table.columns]
     csv_outfile = json2csv(self.table_name(), header_values=keys)
     return sort_csv(csv_outfile)
示例#7
0
 def to_csv(self):
     """Export table from json engine to CSV file"""
     keys = self.table.get_insert_columns(join=False, create=True)
     csv_outfile = json2csv(self.table_name(), header_values=keys)
     return sort_csv(csv_outfile)