![]() Your XML input should be record oriented in order to get good results. Sde1aa68da126ddfe,Time To Say Goodbye,275. XML To CSV Converter This conversion is now available as an API at ConvertCsv.io You can also force double quotes around each field value or it will be determined for you. $ xml sel -t -m '//song' -v 'concat(id, ",", name, ",", duration)' -n artist.xml | sed '$d' >artist.csv # convert xml to csv file using xmlstarlet You can do it all by hand with sqlite3 and xmlstarlet. ![]() (Of course an installation of SQLite itself (commandline and/or GUI tools) so you can look at your DB files and tweak them may be nice, as may graphical XML editors such as oXygen or XMLmindto look at and/or tweak your XML, but neither kind of tool is at all needed, not at all related to using Python rather than other languages for the XML parsing and SQLite writing -).Īnd yes, you can perfectly well do CREATE TABLE and other DDL queries from sqlite3 (and any other DB-API compliant Python module, if you choose to use other relational DBs -). Once you fully understand etree and sqlite3 - and you don't necessarily need to install anything for either (which is part of their charms -) - you're basically all set. If you need a general tutorial on how Python likes to interface to relational DBs (the "DB-API"), there's a nice one here. I recommend sqlite3 (also in the standard Python library) as the relational DB of choice (if you have a choice), again because it's handy and easy - the underlying SQLite embedded relational DB is also well documented at its own site. I recommend you study on ElementTree for parsing your XML file into memory (parse it all, then emit it all to a SQL DB, is probably easier, but element-tree also allows incremental operation if your file is huge) - it's part of the standard Python library as module xml.etree.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |