Which of the following is an example of what text would look like in a comma delimited file?
Updated: 02/01/2021 by Show CSV is a simple file format used to store tabular data, such as a spreadsheet or database. Files in the CSV format can be imported to and exported from programs that store data in tables, such as Microsoft Excel or OpenOffice Calc. CSV stands for "comma-separated values". Its data fields are most often separated, or delimited, by a comma. Example spreadsheet dataFor example, let's say you had a spreadsheet containing the following data.
The above data could be represented in a CSV-formatted file as follows: Sally Whittaker,2018,McCarren House,312,3.75 Belinda Jameson,2017,Cushing House,148,3.52 Jeff Smith,2018,Prescott House,17-D,3.20 Sandy Allen,2019,Oliver House,108,3.48Here, the fields of data in each row are delimited with a comma and individual rows are separated by a newline. Creating a CSV fileA CSV is a text file, so it can be created and edited using any text editor. More frequently, however, a CSV file is created by exporting (File > Export) a spreadsheet or database in the program that created it. Click a link below for the steps to create a CSV file in Notepad, Microsoft Excel, OpenOffice Calc, and Google Docs.
Notepad (or any text editor)To create a CSV file with a text editor, first choose your favorite text editor, such as Notepad or vim, and open a new file. Then enter the text data you want the file to contain, separating each value with a comma and each row with a new line. Save this file with the extension .csv. You can then open the file using Microsoft Excel or another spreadsheet program. It would create a table of data similar to the following:
In the CSV file you created, individual fields of data were separated by commas. But what if the data itself has commas in it? If the fields of data in your CSV file contain commas, you can protect them by enclosing those data fields in double quotes ("). The commas that are part of your data are kept separate from the commas which delimit the fields themselves. For example, let's say that one of our text fields is a user-created description that allows commas in the description. If our data looked like this:
To retain the commas in our "Notes" column, we can enclose those fields in quotation marks. For instance: Lead,Title,Phone,Notes Jim Grayson,Senior Manager,(555)761-2385,"Spoke Tuesday, he's interested" Prescilla Winston,Development Director,(555)218-3981,said to call again next week Melissa Potter,Head of Accounts,(555)791-3471,"Not interested, gave referral"As you can see, only the fields that contain commas are enclosed in quotes. The same goes for newlines which may be part of your field data. Any fields containing a newline as part of its data need to be enclosed in double quotes. If your fields contain double quotes as part of their data, the internal quotation marks need to be doubled so they can be interpreted correctly. For instance, given the following data:
We can represent it in a CSV file as follows: Player Name,Position,Nicknames,Years Active Skippy Peterson,First Base,"""Blue Dog"", ""The Magician""",1908-1913 Bud Grimsby,Center Field,"""The Reaper"", ""Longneck""",1910-1917 Vic Crumb,Shortstop,"""Fat Vic"", ""Icy Hot""",1911-1912Here, the entire data field is enclosed in quotes, and internal quotation marks are preceded (escaped by) an additional double quote. Here are the rules of how data should be formatted in a CSV file, from the IETF's document, RFC 4180. In these examples, "CRLF" is used to represent a carriage return and a linefeed (which together constitute a newline).
Microsoft ExcelTo create a CSV file using Microsoft Excel, launch Excel and then open the file you want to save in CSV format. For example, below is the data contained in our example Excel worksheet:
Once open, click File and choose Save As. Under Save as type, select CSV (Comma delimited) or CSV (Comma delimited) (*.csv), depending on your version of Microsoft Excel. After you save the file, you are free to open it up in a text editor to view it or edit it manually. Its contents resemble the following: Item,Cost,Sold,Profit Keyboard,$10.00,$16.00,$6.00 Monitor,$80.00,$120.00,$40.00 Mouse,$5.00,$7.00,$2.00 ,,Total,$48.00Note The last row begins with two commas because the first two fields of that row were empty in our spreadsheet. Don't delete them — the two commas are required so that the fields correspond from row to row. They cannot be omitted. OpenOffice CalcTo create a CSV file using OpenOffice Calc, launch Calc and open the file you want to save as a CSV file. For example, below is the data contained in our example Calc worksheet.
Once open, click File, choose the Save As option, and for the Save as type option, select Text CSV (.csv) (*.csv). If you were to open the CSV file in a text editor, such as Notepad, it would resemble the example below. Item,Cost,Sold,Profit Keyboard,$10.00,$16.00,$6.00 Monitor,$80.00,$120.00,$40.00 Mouse,$5.00,$7.00,$2.00 ,,Total,$48.00As in our Excel example, the two commas at the beginning of the last line make sure the fields correspond from row to row. Do not remove them! Google DocsOpen Google Docs and open the spreadsheet file you want to save as a CSV file. Click File, Download as, and then select CSV (current sheet). What a CSV file looks like?A CSV is a comma-separated values file, which allows data to be saved in a tabular format. CSVs look like a garden-variety spreadsheet but with a . csv extension. CSV files can be used with most any spreadsheet program, such as Microsoft Excel or Google Spreadsheets.
What is Comma Separated example?Short for comma-separated values, CSV is tabular data that is saved as plaintext data separated by commas. For example, if you had data in CSV format, similar to the example below, that data could be converted to table format. Example CSV data.
Which of the following could be used as a delimiter in a CSV Comma Separated Values file?A CSV file stores data in rows and the values in each row is separated with a separator, also known as a delimiter. Although the file is defined as Comma Separated Values, the delimiter could be anything. The most common delimiters are: a comma (,), a semicolon (;), a tab (\t), a space ( ) and a pipe (|).
What is a delimited file?A delimited file is a sequential file with column delimiters. Each delimited file is a stream of records, which consists of fields that are ordered by column. Each record contains fields for one row. Within each row, individual fields are separated by column delimiters.
|