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'):
self.fieldSeparator = fieldSeparator
self.textDelimiter = textDelimiter
self.encoding = encoding