Best Practices for Creating a CSV File for Import
Consider the below points while creating your input csv file.
Best Practice | Example |
---|---|
Each record should be located on a separate line, delimited by a line break (<CRLF>). |
aaa,bbb,ccc <CRLF> zzz,yyy,xxx <CRLF> |
The last record in the file may or may not have an ending line break. |
aaa,bbb,ccc <CRLF> zzz,yyy,xxx |
There maybe an optional header line appearing as the first line of the file with the same format as normal record lines. This header should contain names corresponding to the fields in the file and the same number of fields as the records in the rest of the file. Note: The presence or absence of the header line should be indicated via the optional "header" parameter of this MIME type. |
field_name, field_name, field_name <CRLF> aaa,bbb,ccc <CRLF> zzz,yyy,xxx <CRLF> |
Within the header of each record, there may be one or more fields, separated by commas. Each line should contain the samenumber of fields throughout the file. Spaces are considered part of a field and shouldn’t be ignored. The last field in the record must not be followed by a comma. |
aaa,bbb,ccc |
Each field may or may not be enclosed in double quotes. However some programs, such as Microsoft Excel, do not use double quotesat all. If fields aren’t enclosed in double quotes, then double quotes may not appear inside the fields. |
"aaa","bbb","ccc" <CRLF> zzz,yyy,xxx |
Fields containing line breaks (<CRLF>), double quotes, and commas should be enclosed in double quotes. |
|
If double quotes are used to enclose fields, then a double quote appearing inside a field must be escaped by preceding it with another double quote. |
"aaa","b""bb","ccc" zzz,yyy,xxx <CRLF> |
If double quotes appear inside a field, enclose it in 2 double quotes. |
aa"""a,bbb,c"""cc <CRLF> zzz,yyy,xxx <CRLF> |
After importing, check the "Read from File" in the Import Detailed Status page and verify whether the number of records in the input file is same as in the fields. If the number of records is not same, there is some issue with your parsing. | N/A |
There can be other delimiters like Pipe(|), caret, semicolon, colon, tilde, and so on which are supported in import. | N/A |
If you're using other delimiter such as Pipe, and if that pipe comes inside a field, enclose the fields containing the delimiter inside double quotes, doubling up any double quotes that appear inside the field. |
Example 1:"User | Date | Command" Example 2:"User |""Date| Comm""and" |