AppyPrinciplesGetting started
appy.pod Generating a CSV file

In order to produce a CSV file with POD, you need to:

  • start to write an ODS template first. Note that only the first sheet will be part of the CSV result;
  • define CSV options via a specific attribute named csvOptions on the Renderer;
  • specify an output name ending with ".csv" in Renderer attribute result;
  • run LibreOffice in server mode.

POD, via a Renderer instance, will create an ODS file from your template; it will then call LibreOffice running in server mode to convert it to CSV, with the options as defined on the Renderer.

Here s an example.

from appy.pod.renderer import Renderer, CsvOptions
 
csvOptions = CsvOptions(fieldSeparator=',', textDelimiter='',
                        encoding='latin-1')
 
Renderer('test.ods', globals(), 'test.result.csv', csvOptions=csvOptions,
         overwriteExisting=True).run()

The constructor for class CsvOptions is detailed hereafter. Possible values for every parameter are explained.

    def __init__(self, fieldSeparator=';', textDelimiter='"', encoding='utf-8'):
        # The delimiter used between every field on a single line
        self.fieldSeparator = fieldSeparator
        # The character used to "wrap" every value. Can be the empty string.
        self.textDelimiter = textDelimiter
        # The ODT result's file encoding. Defaults is "utf-8". "latin-1" is also
        # allowed, or any numeric value as defined at the URL mentioned in
        # appy/pod/converter.py, at variable HELP_CSV_URL.
        self.encoding = encoding