Converting text files between formats
Text conversion rarely means one change. A file received from a partner might be in a different encoding, use the wrong line endings, hold fixed-width columns where your system expects commas, and carry header and trailer lines that the importer rejects. Each of these problems is simple on its own, but together they turn a routine import into an afternoon of manual work, and the work has to be repeated for every new file.
TextPipe lets you chain these conversions in a single filter list. The list is applied in order to every file you select, the files are read as a stream so that size is not a limit, and the filter list can be saved and reused the next time the same feed arrives.
Sample input and output
A fixed-width report from an older system looks like this, with a header line and a trailer line:
HDR 20240314
0001JONES LONDON 0045.50
0002SMITH LEEDS 0112.00
TRL 0002
A filter list that deletes the header and trailer lines, cuts the record at the column positions, trims the padding and joins the columns with commas produces:
0001,JONES,LONDON,45.50
0002,SMITH,LEEDS,112.00
Adding a line-ending filter and an encoding filter at the end of the list makes the file ready for a Unix-based loader that expects UTF-8 and LF line breaks.
Typical settings
- Encoding: convert between ASCII, ANSI, OEM, EBCDIC and Unicode code pages.
- Structure: convert fixed-width, comma, tab, pipe and semicolon layouts into one another.
- Clean-up: trim spaces, remove blank lines, strip control characters and change case.
- Output: overwrite, write to another folder or add a suffix to the file name.
Practical applications
Data teams use these chains to standardise feeds from several suppliers before loading a warehouse. Publishers use them to prepare text for typesetting, and consultants use them during system migrations, where data from the old system has to be reshaped to suit the new one. Once a filter list works, it can be run from the command line in the Pro edition.
Common pitfalls
- Filter order matters. Convert the encoding before you search for text that contains accented letters.
- Check how quoted fields that contain the delimiter are treated before splitting columns.
- Test on a copy of one file first, and keep the original files until the output has been verified.
Related pages
For delimited data see CSV processing and tab-delimited files, and for encodings see the character set converter. The database consulting case study and the data conversion solutions page show conversions in practice. Word documents can be processed in the same way with WordPipe batch processing.