Py | Generic XML 2 Relational Data Convertor - Advanced Options
Please have a look into the basic options first -
http://venkat-echo.blogspot.com.au/2015/12/py-generic-xml-2-relational-data.html
1. If you want to force a specific XML Level into a separate table.
In the above example if you want all toppings details in a separate table and each topping as a seperate row in that able, use the following option
Result of above parameter
Result of the above parameter
3. other config.
Venkat's Github page for XML2RD
http://venkat-echo.blogspot.com.au/2015/12/py-generic-xml-2-relational-data.html
1. If you want to force a specific XML Level into a separate table.
In the above example if you want all toppings details in a separate table and each topping as a seperate row in that able, use the following option
#If you want to force a specific XML Level into a separate table. xml2rd.arr_predefined_xmlPath4Tables = ['/items/item/topping']
Result of above parameter
2. If you would like to add/merge/insert different xmlpath to the same table then use the below config. But please note that Merge XML paths as the same DEPTH.
In the above example if you want to merge <batters> and <batterscost> then use this config
# to put multiple XMLPath into the same table. But make sure all XMLPATH are at the same level xml2rd.d_common_table_4XmlPaths = { '/items/item/batters':{'table':'common_table_batter', 'col_prefix':'b_', 'row_type':'batter'}, '/items/item/batterscost':{'table':'common_table_batter', 'col_prefix':'bc_', 'row_type':'batter_cost'} }
Result of the above parameter
3. other config.
- table_prefix
- csv_prefix
- adding column columns/additional info columns to add table (like filename, date_processed etc)
#If you would to add a prefix to all the tables created. xml2rd.tablename_prefix = "mytab_" #If you would to add a prefix to all the CSVs created. ( like PROCESS_DATE etc) xml2rd.csv_prefix = "ninjaCSV_" #if you would like to add some common value (like filename, date_from file, any other value from the file) #for all column that are not from the XML should be prefix with an underscore ("_") l_xml_filename = "Sample code for all these advanced options are available in test_xml2rd_advanced.py and entire code is available in" l_xml_filename_date = " " l_anyother_info = "any other info you need in the table" xml2rd.d_common_key_values = {'_filename':l_xml_filename, '_file_date': l_xml_filename_date, "_any_other_info":l_anyother_info}
Venkat's Github page for XML2RD
Comments