csv2odf is a command line tool that can convert a comma seperated value (csv) file to an odf document (ods or odt). csv2odf is useful for creating reports from databases and other data sources that produce csv files. csv2odf can be combined with cron and shell scripts to automatically generate business reports.
The csv data is merged with a template file to produce the output file. The template is a standard open document file as produced by OpenOffice.org (www.openoffice.org). The template can be a spreadsheet file (ods) or document file (odt).
If the template is a spreadsheet, the first row will be treated as a header row (Override with -H). The second row is repeated for every row in the csv file. The formatting in the second row cells will be applied to each data cell of the output file. In a spreadsheet template, the second row needs to contain some data: cells that may contain letters (not just numbers) should have letters; adjacent cells should not contain repeated data or else OpenOffice may merge/compress them.
If the template is a document, it must contain a table that the csv data will be inserted into. The table will be processed the same as a spreadsheet.
In the header or footer of the template, you can insert a [date] tag (the word "date" enclosed in brackets). The date tag will be replaced by the current date. The date format can be changed using format codes (see below), for example [date %Y-%m-%d] will produce a date like 2008-02-04. A date with a day offset from the current date can be created by using +n or -n, for example [date-1] would insert the date before today.
For more details see the [Manual].
csv2odf requires Python 2.5 or 2.6. OpenOffice.org (www.openoffice.org) is also needed to create templates and view output files. It can run on any operating system that Python and OpenOffice.org run on, including Linux, Mac, and Windows.
csv2odf has been tested with python 2.5 and 2.6; and with OpenOffice.org 2.4 and 3.0.
If you test with other versions of these programs, you can send your results.
Download Latest tar.gz (sourceforge.net)
We also release a deb file!
sudo dpkg -i csv2odf-1.00-1.deb
Run:
python csv2odf
See the [Manual]
Example Files
File Type What it is
ExampleReport.csv (sourceforge.net)
csv
Sample csv data file
ExampleTemplate.ods (sourceforge.net)
ods
Spreadsheet template example
ExampleTemplate.odt (sourceforge.net)
odt
Document template example
ExampleReport.sh (sourceforge.net)
shell script
example script for running csv2odf
ExampleReport.ods (sourceforge.net)
ods
Spreadsheet output example
ExampleTemplate.odt (sourceforge.net)
odt
Document output example