3 ms·
> Can you write (say) a Python program that will answer any of the above about an OpenOffice .odp file? Using the libraries or packages available from the Open
by da_chicken 9y ago
> Can you write (say) a Python program that will answer any of the above about an OpenOffice .odp file?
Using the libraries or packages available from the OpenDocument home page? (http://opendocumentformat.org/developers/ http://opendocumentformat.org/developers/) Probably, yes. Four of your five questions questions are just: "Is there an API?" The answer is: Yes, yes there is. Did you try searching for an Open Document API? For the image file one, however, all you really need is ZipFile.infolist() because ZIP files already have an API.
> All I'm trying to say is that if OpenOffice .odp files were SQLite databases with a sensible schema, then probably you could answer any of the questions above with perhaps 5 lines line of code or less.
Most of the questions involve an XQuery against content.xml. You could iterate through the files, extract content.xml, and apply the XQuery. No, it's not easy to write the correct XQuery because XQuery sucks and the schema is complex, but it can definitely be done.
I don't know why you think it's going to be magically simplified by changing the storage method. You'd either have compressed XML BLOBs like the article's first suggestion -- which puts you right back where you already are -- or you'll have dozens of tables with a ton of metadata and document structure to dig through. Either way you will need a schema reference to understand what's going on. An RDBMS isn't going to make the content simpler. The schemas are complex because the documents are potentially very complex.
- SQLite 9y ago> I don't know why you think it's going to be magically simplified by changing the storage method. Because ZIP is a key/value store and SQLite is relational. (Later:) Here is a slide comparing SQLite to ZIP from a talk I'm scheduled to give on Monday: https://sqlite.org/tmp/sqlite-v-zip.jpg https://sqlite.org/tmp/sqlite-v-zip.jpg Both SQLite and ZIP will store files and both are well-established open formats with a trillion instances in the wild. SQLite does everything ZIP does but also gives you transaction, a rich query language, a schema, and the ability to store small (1-8 byte) objects and to translate objects into the appropriate byte-order for the reader.