![]() |
To automatically concatenate (join) huge text files, follow these steps:
- Drag and drop your files from Windows Explorer to the TextPipe filter window (they will then get added to the Files To Process tab)
- Re-order the file list as necessary, as the files get concatenated (joined) in the order shown
- Click on the Filters To Apply tab
- In the All Available Filters view, click on Special\Merge (join) files to add it to the My Filter List view
- Enter the name of your output file in the Merge files to box
- Click the Go button at the base of the screen.
If you also want to sort the files, after Step 4, add a Sort filter from Filters\Special\Sort.
Join, concatenate and sort huge text files with TextPipe™ Pro, our multi-award winning, industrial strength text conversion, transformation, cleansing and extraction workbench.
- Joins both text and binary files
- Add a new file header or footer using the Add Header or Add Footer filter
- Remove existing header lines
- Sort the merged file, and remove duplicates
- Restrict changes to line ranges, column ranges, tab fields and much more (see white paper here)
- Convert between Mainframe EBCDIC and PC/Unix ASCII representations (see white paper here)
- Remove or extract lines matching a pattern or a code
- Convert between Unix, PC and Mainframe end-of-line formats
- Convert between Mainframe EBCDIC and PC/Unix ASCII representations
- Remove line ranges and column ranges
- Remove multiple white space
- Write custom code filters in VBScript or JScript
- Handles files of unlimited size - even larger than 10 GB!
- Can be fully automated or scripted
When to merge files
Systems often write output in many small pieces: one log file per day, one export per branch office, one extract per month. Analysis, loading and archiving are easier when the pieces form one file. Joining files by hand with the Windows copy command works for a few small files, but it cannot remove repeated header rows, cannot sort, and becomes awkward with thousands of files.
Example: monthly branch exports
Twelve branch files each start with the same header line. You want one file with a single header.
branch_jan.csv: id,name,total merged.csv: id,name,total
1,Ann,100 1,Ann,100
branch_feb.csv: id,name,total 2,Bob,250
2,Bob,250
Add the merge filter, then use a remove line range filter restricted to the first line of each source file, and add one header back with the Add Header filter. The result is a clean combined file, however large.
Tips for reliable merges
- Check the file order on the Files To Process tab, because files are joined in that order.
- Make sure every file ends with a line break, or add one with a filter so the last line of one file does not run into the first line of the next.
- Convert mixed end-of-line formats and code pages before merging so the output is consistent.
- Run the filter list from the command line or a script to merge each night's files automatically.
- Test the filter list on three or four small sample files first, then compare the line count of the output with the combined line count of the inputs.
Merging by name pattern and keeping a source column
You rarely want to merge every file in a folder. On the Files To Process tab you can include only names that match a wildcard, such as branch_*.csv, and skip folders of old or temporary data. When the origin of each row matters later, add a filter that inserts the source file name at the start of every line, so the merged file still shows which branch or day each record came from. This is useful for audits, where a single odd transaction must be traced back to its original export.
Merging very large files
TextPipe reads and writes in a stream, so memory use stays low even when the combined output is many gigabytes. A month of web server logs, one file per day, can be joined into a single file in a few minutes and then passed to a grep or sort filter in the same job. The run log lists each input file and the number of lines read, so you can check that the total matches the sum of the originals before deleting anything.
Related pages
After merging, you may want to sort and remove duplicates, split the file again for Excel, or clean fields as described in the CSV guide. Mainframe extracts can be combined after EBCDIC conversion. See the systems integration solutions page for larger data consolidation projects. To combine or update many Word documents, see WordPipe.
| Ask Us a Question! | |
