Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m writing a Python script that involves going through a bunch of OpenDocument

ID: 656641 • Letter: I

Question

I'm writing a Python script that involves going through a bunch of OpenDocument text files in a directory tree and sorting them based on a text field that always occurs in the same place in each file.

For this, I need a Python library that allows me to read in text from an OpenDocument text file. Since these files can be quite large, it would be great if the library had a way to read in the first line or so of a file (as the text field I'm looking for always shows up in the first line), as well as a way to iterate through the lines of a file.

Explanation / Answer

The python package ezodf2 should do the job nicely as it can open, edit and create odf format documents.