CSV – basic reading/writing
CSV, which stands for comma-separated values, is one of the most common formats for data exchange. While there is no official standard that defines what a CSV file is, most developers and users would loosely consider it to be a plain text file, where each line in the file represents a row of data, and within each row, there are delimiters between each field to indicate when one record ends and the next begins. The most commonly used delimiter is a comma (hence the name comma-separated values), but this is not a hard requirement; it is not uncommon to see CSV files that use a pipe (|
), tilde (~
), or backtick (`
) character as the delimiter. If the delimiter character is expected to appear within a given record, usually some type of quoting surrounds the individual record (or all records) to allow a proper interpretation.
For example, let’s assume a CSV file uses a pipe separator with the following contents:
column1|column2
a|b|c
...