How to Read and Create CSV Files
CSV files, or comma-separated-files, are used for storing data. They are a very commonly used text file format.
A text editor.
Open your text editor, and save the file with the .csv file extension. Make sure it does not have .txt at the end. Within the file, write the following as sample data:
CSV files, as per their name, are separated by commas, with no spaces in between the different values. Each value between commas, is a field that is recognized by any tool or program that understands .csv files. This can be a custom tool or script, or can be a commercial application like Microsoft Excel. For instance, if you were to open this in Excel, each value separated by a comma would be presented in its own column. To indicate a new row of data, all you would need to include formatting-wise, is a newline at the end of each line. This can be done by entering the new row on a new line, such as by pressing the “Enter” button, as the sample data above demonstrates.
Elements in CSV files are not limited to being separated by commas, however. They can be separated, or delimited, by any terminator, as long as it is consistent. This can be a “|” character, for instance. The file extension would remain the same, .csv. The tool, program, or application used to read the file would need to understand the delimiter designation, however. This can sometimes be set.