How to: Convert a text file to CSV format
As you remember, CSV is just plain text stored in a file. So, occasionally you may receive (or create!) data in a ".txt" (text) file format instead of ".csv". The beauty of the ".csv" format is that you can open it in a spreadsheet and view it in a more traditional, tabular form.
You want to see this, versus that...
Or, it may be that you need to upload the data to an app or database. Most don't accept text files, but they almost certainly accept CSV - the universally loved format.

Whatever the case may be, you may wish to convert your text file to CSV format. And it's very easy to do...

Converting text files to CSV

  1. Open your ".txt" file in the default program (typically Notepad if you're on a PC, or Text Edit if you're a Mac person).
  2. For PC, head to the "File" menu, and choose "Save as". You'll type in the name of your file, and add the extension ".csv". This will automatically change it to CSV format!
  3. For Mac, select "File" and then "Rename" - again, you'll name the file and include the ".csv" extension at the end.
That is all! Simply adding the ".csv" extension to a text file will change the file format itself to ".csv".

Of course with anything that simple, there has to be a disclaimer...

Remember that if your end goal is to have tabular data in CSV format, this requires that the data itself in the file is formatted correctly. Simply converting a text file to CSV will not magically create commas or headers or anything else you'd expect, if it didn't exist already.

So, before converting, check that your text file has each value separated by a comma (or other delimiter). Check that you have a header row. Check that each "row" is structured the same way (i.e. follows the order of the header, and is separated by commas), and so on. That way, when you do convert to CSV, it looks and behaves as you would expect!