Let's look at the most common ways to get a CSV file:
Editing data in a spreadsheet program, such as Excel, Numbers, or Google Sheets
If you're working with data in a spreadsheet, you can save it in CSV format. In that case, you don't need to do anything with the data itself. Instead, just use "Save As" and the ".CSV" option (just like you save to ".XLS" or ".TXT" and so on). This will save your file in CSV format. Similarly, you can use the "Export to" or "Download" and ".CSV" options to save a copy of the file to your computer in CSV format.
Downloading (exporting) data from your programs
This method is different in a sense from the previous one because you're not so much generating a file from the tubular data you've edited in a spreadsheet, but you're downloading data from your database in CSV format. But in fact, you are creating a CSV file that you can just as easily use to move to other programs, edit the data, or back it up.
Unfortunately, not all applications or programs allow you to download data from their systems, so you may have to use third-party tools to get your data in CSV format.
Using a text editor program (such as Notepad or Text Edit, etc.)
Although not common, you can work with a small amount of data and in a text editing program. Just make sure you use commas (or other widely accepted delimiter) to structure the data, where each comma or delimiter represents a "column" of data. Use "Save As" and select "CSV" from the list of options. Depending on the text editor you are using, you may have to enter the actual extension in the file name, such as "File.CSV".