CSV (Comma Separated Value) Writer Parameters
Output File Parameters
Enter the file name extension for the output file. The default is .csv.
This option is used only when adding a new writer and serves to provide a default value for any feature types associated with this writer, setting the option with the same name.
- Yes: Existing files will be overwritten if a matching CSV file was found in the destination folder.
- No: Rows will be appended to existing files if a matching CSV file was found in the destination folder.
Fields
The single-character or tab character specified as the delimiter between values. The default is the comma character.
Specifies whether to write a row containing the field names to the output file.
When this parameter is set to If Writing First Row, the field names will only be written when writing a new file – that is, when Overwrite Existing File is set to Yes (or it is set to No and there is no existing file).
Encoding
This parameter is applicable if you are working with foreign (non-English) character sets. If your source data contains foreign characters, using this parameter along with the encoding value ensures that the original data is preserved from the reader to the writer.
By default, the writer produces UTF-8 encoded documents.
FME supports most encodings.
Specifies whether the Byte Order Mark (BOM) for a UTF-encoded file should be written at the beginning. This option applies only when the character encoding is set to a UTF encoding.
Advanced
Unsafe Characters
Several of the parameters below reference “unsafe” characters. These are characters that could cause the output file to be misinterpreted when present in an attribute value. Here are some examples of unsafe characters:
Character Type |
Example |
---|---|
Delimiters |
An attribute whose value is abc,def would be interpreted as two fields when read back, rather than one. |
Leading field qualifiers |
An attribute whose value is “abc would cause all values after that to be interpreted as part of the same value if there was no closing field qualifier. |
Newlines |
An attribute whose value is abc def would be interpreted as two separate lines. |
By default the writer will enclose values that contain unsafe characters in the field qualifier character, which should allow them to be interpreted correctly. However, there are options to adjust this handling.
Specifies whether the field names written on the first row of the file are quoted.
- Yes: Field Names will be quoted.
- No: Field names will not be quoted.
- If Needed: This is the default choice. Field names will be quoted if they contain one or more unsafe characters.
Specifies whether the field values should be qualified (that is, enclosed in field qualifier characters).
- Yes: Every field, including Field Names, is quoted.
- No: Zero fields are quoted. (Note that this does not guarantee that values will be unmodified.)
- If Needed: This is the default choice. Values will be quoted if they contain one or more unsafe characters.
When Qualify Field Values is set to No, this parameter tells the writer what to do when a value contains an "unsafe" character (such as a delimiter or a leading field qualifier). The usual behavior is to Remove Unsafe Characters and log a warning.
In some cases, however, you might want to preserve these characters even if they can produce inconsistent data. If you choose to Preserve Unsafe Characters, you should ensure that you understand how this parameter will affect your output data.
Say, for example, you are writing the following two values:
a = ""abc""
b = def"
FME will strip all leading field qualifiers, and write the line:
abc"",def"
If read back, the values would look like this:
a = abc""
b = def"
Remove Unsafe Characters – Unsafe characters will be removed from the value to ensure the file can be read correctly. For example, a value abc,def will be written as abc def (the delimiter will be removed). This is the default choice. The following characters will be removed:
- Delimiters will be replaced by a space. If the delimiter is a space, it will be replaced by |
- Leading field qualifiers will be removed
- Newlines will be removed
Preserve Unsafe Characters – Unsafe characters will be written as-is. This may result in the output file being misinterpreted when read back.
Specifies the character that encloses field values. The default is the quotation mark character.
When a field starts with this character, all text that follows this character and precedes the next occurrence of the character will be treated as one value, even if that text contains a delimiter or newline character.
Specifies the character that escapes the field qualifier character.
This is used when you want to have a field qualifier literal within a field qualifier group.
Specifies end-of-line character to use.
Note that this will only be used to terminate rows, and that individual values that contain newline characters will not be modified to conform to this option.
A schema configuration file contains formatting information about text files located in the same file directory. These files are always named schema.ini and contain information about field names and types, the field separation character, and more. This file can be used when loading table data into ArcGIS. See https://msdn.microsoft.com/en-us/library/ms709353(v=vs.85).aspx for more details.
- When this option is checked, schema configuration file is created along with the output CSV file(s).
- When this option is unchecked, a schema configuration file is not created.
Existing Schema File Handling
Specifies whether entries will be prepended to an existing schema file if one already exists.
- Overwrite: Overwrite the existing schema.ini files, if any are present.
- Prepend: If a schema.ini file already exists in the output directory, prepend new information to the existing file.
Note: Entries will not be added to the schema.ini file when appending to an existing .csv file (that is, Existing File Handling is set to Append, and the file already existed). It is assumed in this case that the schema file already has an entry for the corresponding .csv file.
Note: ArcGIS will only take into account the first config entry encountered for each CSV file, meaning the latest entries should be at the top of the file (this is why prepend is preferred over append).