An easy-to-follow tutorial on making CSV files
Do you need to create a CSV file for your data? A CSV (comma-separated values) file allows you to save your data in a table-structured format, which is useful when importing data into databases or web applications. You can create a CSV file from scratch using a text editing program or a spreadsheet program. This wikiHow article teaches you how to create CSV files using Microsoft Excel, OpenOffice Calc, Google Sheets, and in a text editor.
How to Create a CSV File
- You can make a CSV in a text editor like Notepad. Separate each data field with a comma (no spaces), put each row on a separate line, and save the file as a ".csv".
- To save a spreadsheet as a CSV in Excel, go to File > Save as and select CSV as the file type.
- In Google Sheets, go to File > Download , then select Comma Separated Values (.csv) .
Steps
-
Open a text editor program. Because CSV files are just plain text files in a specific comma-separated format, you can use your computer's built-in text editor to create one. You can use Notepad on Windows, or TextEdit on Mac. You can also use programs like Microsoft Word or Pages on Mac. [1] X Research source
-
Type your field names separated by commas onto the first line. For example, if entering data for items you’re selling, type the following onto the first line: “Name,Price,Description.” There must be no spaces between items.Advertisement
-
Type your data onto the second line. Each row in a CSV goes on a separate line. Use the same format as your field names on the first line. Using the example outlined in step #1, write the actual item name, followed by the item’s price and description. [2] X Trustworthy Source Microsoft Support Technical support and product information from Microsoft. Go to source
- For example, if selling baseballs, write “Baseball,5.99,Sports.”
-
Continue typing your data for each individual item onto each subsequent line. If leaving any fields empty, make sure you include the comma, or the remaining fields will be off by one.
-
Save your file in CSV format. You'll need to make sure you are saving your file as a CSV file (with the ".csv" file extension) rather than a text file (with the ".txt" extension). Use the following steps to do so:
- Click File in the menu bar at the top.
- Click Save as .
- Use the drop-down menu next to "Save as Type" to select All files .
- Enter a filename for the file next to "Filename."
- Add the extension ".csv" to the end of the filename (i.e. "inventory.csv").
- Click Save .
Advertisement
-
Open or create a spreadsheet in Excel. You can open an existing spreadsheet file, or you can create a new spreadsheet using Excel .
- To open an existing spreadsheet, right-click the spreadsheet file (i.e., ".xls," ".xlsm," ".xlsb, ".xlr," ".xlw") and click Open with . Then select Microsoft Excel . [3] X Trustworthy Source Microsoft Support Technical support and product information from Microsoft. Go to source
-
Click File . It's in the menu bar at the top of the screen. This displays the "File" menu to the left.
-
Click Save as . It's about halfway down the "File" menu. This displays the "Save as" menu.
-
Enter a filename for the file. Use the first bar at the top of the Window to enter a name for the file.
-
Select a CSV file type. Use the drop-down below the bar where you enter your filename to select one of the "CSV" file types. There are a few CSV file formats to choose from. They are as follows:
- "CSV (comma delimited)" is the most common CSV file format and is typically used on Windows computers. Select this format if your file will be used with Windows computers.
- Select "CSV UTF-8 (Comma delimited)" if your file has special characters or will be used in a program that requires the "CSV UTF-8" format.
- Select "CSV (Macintosh)" if your CSV file will be used on a Mac computer more than Windows.
- Select "CSV (MS-DOS)" if your CSV file is going to be used in DOS or the Windows command line.
-
Click Save . It's next to the drop-down menu where you select the file type. This saves the file as a CVS file. You can import CSV files into Export, Google Sheets, and other spreadsheet programs, or you can open it as a text file in Notepad or TextEdit. [4] X Trustworthy Source Microsoft Support Technical support and product information from Microsoft. Go to source
Advertisement
-
Open or create a new spreadsheet in Google Sheets. To do so, go to https://docs.google.com/spreadsheets/ in a web browser. Click one of the spreadsheets in the list of files, or click Blank spreadsheet at the top to create a new spreadsheet. Then edit your spreadsheet or enter data into the cells to make a new spreadsheet .
- Alternatively, you can use the Google Sheets mobile app on your mobile device.
-
Click File . It's the first option in the menu bar at the top.
- If you don't see the menu bar at the top, click the bracket icon pointing down "🇻" in the upper-right corner.
-
Click Download . It's in the file menu. This displays a menu with several file types you can select to download the file.
-
Click Comma Separated Values (.csv) . This will download the file as a CSV file. You can find your downloaded files in your Downloads folder by default.
Advertisement
-
Open or create a new spreadsheet in LibreOffice Calc. LibreOffice Calc is a free and open-source alternative to Microsoft Excel. It comes bundled with the LibreOffice software package.
- LibreOffice Calc supports LibreOffice and OpenOffice spreadsheets (".ods" files), as well as Excel spreadsheets (".xls" and ".xlsx" files). To open an existing file, right-click it and click Open with . Then select LibreOffice Calc . Enter your data into the cells to edit your spreadsheet.
- To start a new spreadsheet, click the LibreOffice Calc icon in the Windows Start menu or Applications folder on Mac. Then click File followed by New . Click Spreadsheet .
- You can download LibreOffice for free at https://www.libreoffice.org/download/download-libreoffice/ . It is available for Windows, Mac, and Linux.
-
Click File . It's in the menu at the top of the page. This displays a drop-down menu.
-
Click Save as . It's about halfway down the File menu.
-
Enter a filename for the file. Enter the name you want to save the file as in the bar next to "File name."
-
Select a CSV file type. Use the drop-down menu below the bar where you enter the file name to select "Text CSV."
-
Click Save . It's in the lower-right corner of the page. This displays a pop-up that informs you that your document may contain text that can't be saved in the CSV format.
-
Click Use Text CSV Format . This opens an "Export Text File" dialogue box you can use to select some options for your CSV file.
-
Select the options for your CSV file. There are quite a few options you can select for your CSV file. They are as follows: [5] X Research source
- Character set:
Use this drop-down menu to select the character set you want to use.
- By default "Western Europe (Windows)" is selected. Leave this as is if you are going to be using your CSV file in Windows.
- If you are going to be using your CSV file on a Mac, select "Western Europe (Apple Macintosh)."
- If your CSV file has special characters, you can select "Unicode (UTF-8) or Unicode (UTF-16)." You can also select "Western Europe (ASCII/US)."
- You can also select options for DOS and IOS.
- If you want to use different language characters, you can select Arabic, Baltic, Chinese (Simplified or Traditional), Cyrillic, Eastern Europe, Greek, Hebrew, Japanese, Korean, Latin, Thai, or Turkish.
- Field delimiter: This allows you to select what character delimits each field or cell. By default, this is set as a comma, though you can select a different character (such as a semi-colon) if you want.
- String delimiter: This allows you to select what character delimits a string. By default, this is set to a quotation mark.
- Save cell content as shown: This displays cell content as shown in the spreadsheet. This box is checked by default. If it is not checked, it will display raw data instead of cell content.
- Save cell formulas instead of calculated values: Check this checkbox if you want the CSV file to display the formulas in a cell instead of the calculated numbers they reach.
- Quote all text cells: This puts all text cells in quotes. This is useful if any of your cells contain commas, as it will distinguish between a comma that separates a value and a comma that's part of the text.
- Fixed column width: This fixes the columns in your CSV file to the same width as they appear in the spreadsheet. If the text in a cell is longer than the width of the column, the text will be truncated.
- Character set:
Use this drop-down menu to select the character set you want to use.
-
Click Ok . It's in the lower-right corner of the dialogue box. This saves the CSV file with the preferences you selected. You can edit a CSV file in a text editing program like Notepad or TextEdit. You can also import it into a spreadsheet program like LibreOffice Calc or Microsoft Excel.
Advertisement
Community Q&A
Search
-
QuestionHow do I execute a CSV file?Community AnswerCSV files are not executables, so you can’t “run” it like an app. These files are usually read by programs that use it as data.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Video
Tips
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
References
- ↑ https://support.apple.com/guide/textedit/open-documents-txte51413d09/mac
- ↑ https://support.microsoft.com/en-us/office/create-or-edit-csv-files-to-import-into-outlook-4518d70d-8fe9-46ad-94fa-1494247193c7
- ↑ https://support.microsoft.com/en-us/office/file-formats-that-are-supported-in-excel-0943ff2c-6014-4e8d-aaea-b83d51d46247
- ↑ https://support.microsoft.com/en-us/office/import-or-export-text-txt-or-csv-files-5250ac4c-663c-47ce-937b-339e391393ba
- ↑ https://help.libreoffice.org/24.8/en-US/text/shared/00/00000207.html
About This Article
Thanks to all authors for creating a page that has been read 446,028 times.
Advertisement