示例#1
0
 def to_csv(self):
     """Export table from xml 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 = xml2csv(table_name, header_values=header)
         sort_csv(csv_outfile)
示例#2
0
 def to_csv(self):
     """Export table from xml 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 = xml2csv(table_name, header_values=header)
         sort_csv(csv_outfile)
示例#3
0
def test_xml2csv():
    """Test xml2csv function
    creates a xml file and tests the md5 sum calculation"""
    xml_file = create_file("<root>\n<row>\n"
                           "<User>Alex</User>\n"
                           "<Country>US</Country>\n"
                           "<Age>25</Age>\n</row>\n"
                           "<row>\n<User>Ben</User>\n"
                           "<Country>US</Country>S\n"
                           "<Age>24</Age>\n"
                           "</row>\n</root>", 'output.xml')
    output_xml = xml2csv(xml_file, "output_xml.csv", header_values=["User", "Country", "Age"])
    obs_out = file_2string(output_xml)
    os.remove(output_xml)
    assert obs_out == "User,Country,Age\nAlex,US,25\nBen,US,24\n"
示例#4
0
def test_xml2csv():
    """Test xml2csv function.

    Creates a xml file and tests the md5 sum calculation.
    """
    xml_file = create_file([
        '<root>', '<row>', '<User>Alex</User>', '<Country>US</Country>',
        '<Age>25</Age>', '</row>', '<row>', '<User>Ben</User>',
        '<Country>US</Country>', '<Age>24</Age>', '</row>', '</root>'
    ], 'output.xml')

    output_xml = xml2csv(xml_file,
                         "output_xml.csv",
                         header_values=["User", "Country", "Age"])
    obs_out = file_2list(output_xml)
    os.remove(output_xml)
    assert obs_out == ['User,Country,Age', 'Alex,US,25', 'Ben,US,24']
示例#5
0
def test_xml2csv():
    """Test xml2csv function
    creates a xml file and tests the md5 sum calculation"""
    xml_file = create_file(
        "<root>\n<row>\n"
        "<User>Alex</User>\n"
        "<Country>US</Country>\n"
        "<Age>25</Age>\n</row>\n"
        "<row>\n<User>Ben</User>\n"
        "<Country>US</Country>S\n"
        "<Age>24</Age>\n"
        "</row>\n</root>", 'output.xml')
    output_xml = xml2csv(xml_file,
                         "output_xml.csv",
                         header_values=["User", "Country", "Age"])
    obs_out = file_2string(output_xml)
    os.remove(output_xml)
    assert obs_out == "User,Country,Age\nAlex,US,25\nBen,US,24\n"
示例#6
0
def test_xml2csv():
    """Test xml2csv function.

    Creates a xml file and tests the md5 sum calculation.
    """
    xml_file = create_file(['<root>', '<row>',
                            '<User>Alex</User>',
                            '<Country>US</Country>',
                            '<Age>25</Age>', '</row>',
                            '<row>', '<User>Ben</User>',
                            '<Country>US</Country>',
                            '<Age>24</Age>',
                            '</row>', '</root>'], 'output.xml')

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