CSV Filter parameters /text/shared/guide/csv_params.xhp CSV;filter options CSV;separator specification line CSV;import options CSV;export options CSV;command line filter options

CSV Filter Options

The CSV filter accepts an option string containing five to fifteen tokens, separated by commas. Tokens 6 to 15 are optional.
Import from UTF-8, Language German, Comma separated, Text delimiter ", Quoted field as text. CSV file has columns formatted as date, number, number, number: soffice --infilter="Text - txt - csv (StarCalc):44,34,76,1,1/5/2/1/3/1/4/1,1031,true,true" test.csv Export to Windows-1252, Field delimiter : comma, Text delimiter : quote, Save cell contents as shown: soffice --convert-to "csv:Text - txt - csv (StarCalc):44,34,ANSI,1,,0,false,true,true" --outdir=/home/user test.ods Token Position Definition Meaning and Example of Token 1 Field Separator Field separator(s) as ASCII values. Multiple values are separated by the slash sign ("/"), that is, if the values are separated by semicolons and horizontal tabulators, the token would be 59/9. To treat several consecutive separators as one, then append '/MRG' to the token. If the file contains fixed width fields, then use 'FIX'. Example: 44 (,) 2 Text Delimiter The text delimiter as ASCII value, like 34 for double quotes and 39 for single quotes. Example: 34 ("). 3 Character Set The character set code used in the file as described in the table below. Example: 0 (System). 4 Line number to start reading. CSV Import N: line number to start reading. Example: 3 (start from third line). 5 Cell Format Codes for Each Column CSV Import A sequence of column/formatting code, where the formatting code is given in the table below. Example: "1/5/2/1/3/1/4/1". If value separators are used, the form of this token is column/format[/column/format/…] where column is the number of the column, with 1 being the leftmost column. The format code is detailed below. If the first token is FIX it has the form start/format[/start/format/…], where start is the number of the first character for this field, with 0 being the leftmost character in a line. The format is explained below. 6 Language identifier String expressed in decimal notation. This token is the equivalent of the "Language" listbox in the user interface for CSV import. If the value is 0 or omitted, the language identifier of the user interface is used. The language identifier is based on the Microsoft language identifiers. 7 Quoted field as text String, either false or true. Default value: false. This token is the equivalent of the check box "Quoted field as text". 8 Detect special numbers Import: String, either false or true. Default value: false. This token is the equivalent of the check box "Detect special numbers". Export: String, either false or true. Default value: true. This token has no UI equivalent. If true, the number cells are stored as numbers. If false, the numbers are stored as text, with text delimiters. 9 Save cell contents as shown CSV Export String, either false or true. Default value:true. This token is the equivalent of the check box "Save cell contents as shown". 10 Export cell formulas CSV Export String, either false or true. Default value: false. Export cell formulas. 11 Remove spaces CSV Import String, either false or true. Default value: false. Remove spaces. Trim leading and trailing spaces, when reading the file. 12 Export sheets CSV Export Export the entire document to individual sheets .csv files or a specified sheet. 0 or absent: means the default behaviour, first sheet from command line, or current sheet in macro filter options, exported to sample.csv -1: for all sheets, each sheet is exported to an individual file of the base file name concatenated with the sheet name, for example sample-Sheet1.csv, sample-Sheet2.csv and sample-Sheet3.csv N: export the N-th sheet within the range of number of sheets. Example: to export the second sheet, set 2 here to get sample-Sheet2.csv 13 Import as formulas CSV Import String, either false or true. Default value: false. Determines whether formula expressions starting with a = equal sign character are to be evaluated as formulas or imported as textual data. If true evaluate formulas on input. If false formulas are input as text. If omitted (not present at all), the default value is true to keep the behaviour of old versions' options string that didn't have this token at all. If present and empty (or any other value than true) the default value is false. 14 Include a byte-order-mark (BOM) String, either false or true. Default value: false. If true include a byte-order-mark (BOM) in the export. If false the export does not include a BOM. If omitted (not present at all), the default value is false to keep the behaviour of old versions' options string that didn't have this token at all. If present and empty (or any other value than true) the default value is false. Automatically detected during the import. 15 Detect numbers in scientific notation String, either false or true. Default value: true. If true detect if a cell content containing an 'E' or 'e' is a number in scientific notation. If false do not try to detect numbers in scientific notation. Token can be false only if token 8 (Detect special numbers) is false. If omitted, the default value is true to keep the behaviour of old versions' options string that didn't have this token at all.

Special case of CSV files with separator defined in the first line

CSV import and export support a sep= and "sep=" field separator setting. When reading a CSV document, the separator is taken from the initial sep= or "sep=" single field, if that is the only line content. When reading a CSV file, the quoted form is preserved as (unquoted) cell content. You see sep=| when | is the separator in the first line. In the unquoted form, the separator is discarded because it is a real field separator in the context. You see sep= in the first line. When writing a CSV file, the existing single top left cell's content such as sep=| is adapted to the current separator with the quoted form of "sep=|" (if quotes / text delimiters aren't set empty and | is the separator) and always uses the ASCII " double quote character. If the line containing the sep=| is not to be imported as data, remember to set the From row number in the dialog to 2. Note that this line will not be preserved when re-saving. sep=| "LETTER"|"ANIMAL" "a"|"aardvark" "b"|"bear" "c"|"cow"

Formatting Codes for Token 5

Meaning Code Standard 1 Text 2 MM/DD/YY 3 DD/MM/YY 4 YY/MM/DD 5 - 6 - 7 - 8 Ignore field (do not import) 9 US-English 10

Character Set Codes for Token 3