Home / Blog / Other text utilities

Plain-text files and table design

Save a TXT File as CSV: Content, Encoding and Filename Checks

Save prepared CSV text with the right extension and encoding, recognize double extensions, and verify the parsed table before importing it into another program.

Save a TXT File as CSV: Content, Encoding and Filename Checks

You can save a TXT file as CSV when its contents already represent a table in CSV syntax, or after converting its existing table structure into that syntax. Choosing a .csv filename does not turn paragraphs, tab-separated records or rich-text instructions into comma-separated fields. Check the content before treating Save As as the final conversion step.

Decide whether the text is ready to save

Read several records and identify the intended columns. A CSV-ready file has clear field boundaries and a consistent representation of quoted values. A line such as Asha,North office,4 can be three fields, while Asha works in the north office is a sentence that still needs a data model.

If the source contains tabs, use a parser configured for tabs and write CSV output. If it contains fixed-width columns, parse their defined positions. If it is already comma-separated, avoid unnecessary retyping or spreadsheet resaving that could change identifiers or date text.

Check a complete example

Code,Label,Quantity
00123,"North, east",4
00999,René,0

This table has three columns and two records. The code 00123 is an identifier; its leading zeros belong to its text. The label North, east is one field because the comma is enclosed within quotation marks. René is a useful check that the selected encoding preserves non-ASCII characters.

An extra comma at the end of one data record would add a fourth empty field. An absent comma between Code and Label would combine two fields. Inspect the parsed table rather than deciding solely from a line’s visual appearance in a text editor.

Save plain text rather than a formatted document

Use a plain-text editor or a plain-text mode. A rich-text document can display the expected words while storing formatting commands around them. Renaming that document does not remove the commands, and a CSV importer may read them as unwanted data.

Use straight double quotes for CSV quoting. If a field contains literal quotation marks, represent them according to the selected CSV dialect, commonly by doubling them inside a quoted field. Do not add typographic quotation marks around every line merely to make the document look polished.

Verify the final filename

Choose a new output name ending in .csv. Some editors append their default .txt extension, producing a name such as output.csv.txt. Display the full extension in your file manager and verify what was actually saved instead of relying on the name you typed into the dialog.

Microsoft’s file-extension guidance explains that changing an extension does not convert file contents. If the saved text is already valid CSV, correcting the final extension can be appropriate. If the content is still a different format, return to the parsing or preparation step first.

Choose encoding deliberately

Use the encoding specified by the recipient. UTF-8 is a common choice, but the destination’s documented requirements decide whether it needs an initial byte-order mark or a particular record-ending convention. An extension carries none of those details.

Reopen the saved file and inspect an accent or other known non-ASCII value. If the value changed during saving, preserve the source and resolve the encoding mismatch. Repeatedly opening and saving garbled text can make it harder to recover the original characters.

Keep saving separate from data interpretation

CSV stores field text rather than a workbook’s cell-format rules. A spreadsheet may display 00123 as 123 after automatic type detection even when the saved file still contains the zeros. Inspect the raw text and use explicit import types to distinguish a file problem from a display or interpretation problem.

The same issue applies to date-like labels and long numeric identifiers. Do not convert every field to a number merely because it contains digits. Decide which fields represent quantities and which are names or identifiers before importing.

Validate before handing over the file

Parse the saved file with the agreed delimiter and quoting rules. Confirm the header, the number of data records and the field count of each record. Include at least one value with a comma, one empty optional value and one non-ASCII value when those cases occur in the real dataset.

Then test a small sample in the actual receiving application. A syntactically valid CSV may still have incorrect header names or column order for that importer. Keep the original TXT, the prepared CSV and a note of the chosen encoding so a later correction can be traced to the right step.