1 | # CSV Formats | 1 | # CSV
|
---|
2 | | 2 |
|
---|
3 | LiteCart tries to support the most common variations of non-standard CSV | 3 | A CSV (Comma-Separated Values) file is a plain text file format commonly used to store tabular data. Each line of the file represents a single row of data, and each value within a row is separated by a comma (,), hence the name "comma-separated values". However, other delimiters like semicolons (;) or tabs (\t) can also be used. CSV files are often used because they are easy to create and manipulate using text editors or spreadsheet software like Microsoft Excel or Google Sheets. They're widely used for importing and exporting data between different software applications and databases.
|
---|
4 | formats but one is prefered. | 4 |
|
---|
5 | | 5 | CSV files are sometimes referred to as TSV (Tab-Separated Values) or DSV (Delimiter-Separated Values) due to the different format variations in delimiters.
|
---|
6 | \^ Format \^ Delimiter \^ Column Wrapper \^ Escape character \^ Encoding | 6 |
|
---|
7 | \^ EOL | CSV | , | " | " | UTF-8 w/o BOM | CR+LF | 7 | ## CSV Formats
|
---|
8 | | 8 |
|
---|
9 | A list of CSV formats supported by applications. | 9 | LiteCart tries to support the most common variations of non-standard CSV formats but the default standard is the one preferred.
|
---|
10 | | 10 |
|
---|
11 | \^ Application \^ Format \^ Delimiter \^ Column Wrapper \^ Escape | 11 | ```txt
|
---|
12 | character \^ Encoding \^ EOL \^ Recommended \^ Comments | Google Docs | 12 | Type: CSV
|
---|
13 | Spreadsheet (Web application) | CSV / TSV | , or TAB | " | " | | 13 | Delimiter: ,
|
---|
14 | Any | CR / LF / CR+LF | **Yes** | | Microsoft Office Excel 2010 | 14 | Encapsulator: "
|
---|
15 | (numerals with decimal point) | CSV (MS-Dos) | , | " | " | UTF-8 | 15 | Escape Character: "
|
---|
16 | w/o BOM | CR+LF | No | Excel 2011/Mac cannot correctly interpret a | 16 | Character Encoding: UTF-8 without Byte Order Mark (w/o BOM)
|
---|
17 | CSV file containing umlauts and diacritical marks no matter what | 17 | Line Endings: Windows CR+LF
|
---|
18 | encoding. | Microsoft Office Excel 2010 (numerals with decimal comma) | 18 | ```
|
---|
19 | | DSV (MS-Dos) | ; | " | " | UTF-8 w/o BOM | CR+LF | No | | 19 |
|
---|
20 | Excel 2011/Mac cannot correctly interpret a CSV file containing umlauts | 20 | ### CSV Formats In Applications
|
---|
21 | and diacritical marks no matter what encoding. | Microsoft Office Excel | 21 |
|
---|
22 | 2011 (numerals with decimal point) | DSV (Mac) | , | " | " | | 22 | ```txt
|
---|
23 | Windows-1252, UTF-8 w/ BOM | CR | No | Many regional versions of | 23 | Application Format Delimiter Column Wrapper Escape character Encoding EOL LiteCart Compliant Comments
|
---|
24 | Excel will not be able to deal with Unicode in CSV. | Microsoft Office | 24 | Google Docs Spreadsheet (Web application) CSV / TSV , or TAB " " Any CR / LF / CR+LF **Yes**
|
---|
25 | Excel 2011 (numerals with decimal comma) | CSV (Mac) | ; | " | " | 25 | Microsoft Office Excel 2010 (numerals with decimal point) CSV (MS-Dos) , " " UTF-8 w/o BOM CR+LF No Excel 2011/Mac cannot correctly interpret a CSV file containing umlauts and diacritical marks no matter what encoding.
|
---|
26 | | Windows-1252, UTF-8 w/ BOM | CR | No | Many regional versions of | 26 | Microsoft Office Excel 2010 (numerals with decimal comma) DSV (MS-Dos) ; " " UTF-8 w/o BOM CR+LF No Excel 2011/Mac cannot correctly interpret a CSV file containing umlauts and diacritical marks no matter what encoding.
|
---|
27 | Excel will not be able to deal with Unicode in CSV. | LibreOffice Calc | 27 | Microsoft Office Excel 2011 (numerals with decimal point) DSV (Mac) , " " Windows-1252, UTF-8 w/ BOM CR No Many regional versions of Excel will not be able to deal with Unicode in CSV.
|
---|
28 | (Multi platform) | CSV / DSV / TSV | Any | " or ' | " | Any | | 28 | Microsoft Office Excel 2011 (numerals with decimal comma) CSV (Mac) ; " " Windows-1252, UTF-8 w/ BOM CR No Many regional versions of Excel will not be able to deal with Unicode in CSV.
|
---|
29 | CR / LF / CR+LF | **Yes** | Supports all variations | 29 | LibreOffice Calc (Multi platform) CSV / DSV / TSV Any " or ' " Any CR / LF / CR+LF **Yes** Supports all variations
|
---|
30 | | 30 | ```
|
---|
31 | w/ BOM = With Byte Order Mark | 31 |
|
---|
32 | | 32 | *w/ BOM* = With Byte Order Mark
|
---|
33 | w/o BOM = Without Byte Order Mark | 33 |
|
---|
| | 34 | *w/o BOM* = Without Byte Order Mark
|
---|
| | 35 |
|
---|
| | 36 | ## Encode CSV From Array
|
---|
| | 37 |
|
---|
| | 38 | ```php
|
---|
| | 39 | $csv = functions::csv_encode($array, $delimiter, $enclosure, $escape, $charset, $eol);
|
---|
| | 40 | ```
|
---|
| | 41 |
|
---|
| | 42 | ## Decode CSV To Array
|
---|
| | 43 | ```php
|
---|
| | 44 | $array = functions::csv_decode($csv, $delimiter, $enclosure, $escape, $charset, $eol);
|
---|
| | 45 | ```
|
---|
| | 46 |
|
---|
| | 47 | Note that the parameters $delimiter, $enclosure, $escape, $charset, $eol are optional. If omitted they will default to the values of the standard first mentioned in this article. |
---|