Home / Blog / Other text utilities

Plain-text files and table design

Convert TXT to CSV on Mac With Plain-Text and Field Checks

Prepare CSV on Mac by identifying the text layout, using plain-text editing and UTF-8, and checking field boundaries instead of relying on a renamed extension.

Convert TXT to CSV on Mac With Plain-Text and Field Checks

To convert TXT to CSV on a Mac, identify the text file’s record structure, express that table using valid CSV syntax and save a plain-text file with a .csv extension. TextEdit can edit the text, but it does not infer columns from arbitrary paragraphs. A tab-delimited or fixed-width source needs a defined parsing step before it becomes comma-separated records.

Inspect a copy of the source

Start by duplicating the source and opening the copy as text. Determine whether fields are separated by tabs, commas or another character, or whether their positions define fixed-width columns. Also determine whether the first record contains field names. A visually aligned document can use spaces for presentation without having an unambiguous table structure.

If the file is already valid comma-separated text and only its extension is wrong, a filename change may be enough. If it contains rich-text formatting instructions, changing .rtf to .csv will not remove them. Preserve the original while distinguishing these cases.

Use TextEdit’s plain-text mode

Apple’s TextEdit conversion guide documents Format, Make Plain Text. That removes document formatting; it does not automatically add CSV separators or convert a visual table into a reliable field layout. Work from a copy because rich-text styles are discarded.

For a small manually prepared CSV, enter one logical record per row and separate fields with commas. Use ordinary straight double quotes where CSV syntax requires them. Inspect the resulting characters if typing substitutions or copied typography have introduced curved quotation marks; curved quotes are data characters, not CSV field delimiters.

Build a small verifiable table

Code,Item,Note
0012,Blue folder,"Shelf A, upper"
0047,Green folder,"Label says ""archive"""

This example has three columns and two data records. The first note contains a comma, so the whole note is quoted. The second note contains quotation marks around archive, represented by doubled straight quotation marks inside the quoted field. The product codes remain textual identifiers with leading zeros.

After parsing, the first note should be Shelf A, upper and the second should be Label says "archive". If a preview shows four fields in the first record, the quotes were removed or not recognized. Correct that structural problem before adding more records.

Check encoding and the actual saved name

TextEdit’s Open and Save settings include plain-text encoding and an option to add .txt to plain-text files. Choose the encoding required by the destination, commonly UTF-8, and verify that the saved file’s final extension is .csv rather than .csv.txt.

Save a new file rather than replacing the only source. If the editor appends .txt, inspect the full filename in Finder and correct the copy’s extension after confirming the contents are already CSV. Changing the name at this stage identifies a format you prepared; it does not itself perform the preparation.

Resolve unreadable characters before editing

If a source name such as René appears garbled, reopen the source using its actual encoding before making edits. Apple’s encoding guidance describes selecting an encoding when opening a text file. Saving misdecoded characters as UTF-8 preserves the wrong characters rather than repairing the original data.

Keep a known non-ASCII value in the test set and compare it with the source after saving. The correct display in one editor is useful evidence, but the destination still needs to read the same encoding.

Use a parser for larger delimited files

For a large tab-delimited source, manual replacement is fragile. The Python TXT-to-CSV example provides a specific tabular contract, checks record widths and writes CSV quoting. It requires a Python environment; this guide does not assume a particular Python installation is included with macOS.

For fixed-width input, obtain column positions and decide whether widths refer to bytes or characters. For free-form notes, identify the intended fields manually before serialization. Neither TextEdit nor a delimiter converter can reliably decide which part of a sentence belongs in which business field without that information.

Verify structure and receiving types

Open the completed file with a CSV-aware preview and confirm its column count, data-record count and field values. Test both example rows and an empty optional field if your real data includes one. A physical line count is insufficient when the chosen CSV dialect permits multiline quoted fields.

Finally, import a small sample into the receiving application with identifier columns treated as text. Confirm that 0012 remains 0012. Local parsing verifies the file structure; the application’s import settings determine whether it keeps the intended types and values.