Large File Splitter By Rows
A tick log, a trade history export, or a bar dump that runs for a few years can easily reach hundreds of thousands of rows. Some spreadsheet builds still cap out at 65,536 or 1,048,576 rows, and even the ones that do not choke badly opening a single huge file. The fix is to cut it into pieces small enough to open comfortably, each one still a valid file on its own with the header row intact. The naive way to write a splitter is to parse each line by delimiter and rebuild it. That is unnecessary work for what is fundamentally a row-count problem, and it introduces a real bug: a quoted CSV field containing the delimiter character gets miscounted as extra columns, and the exported file comes out corrupted in a way the user will not notice until it is opened. This script never looks inside a row. Each line is copied as one opaque string, so whatever is inside a field - commas, semicolons, quoted text - is preserved exactly as the source wrote it. Getting the chunk numbering right needs a first pass over the file before any writing starts. Padding "Part2" to "Part02" only works if the script already knows whether the run will reach double digits, so the first pass counts data rows, and the second pass does the actual split with numbering that sorts correctly in a plain file listing no matter how many chunks there are. Notes and limitations - Output chunks are always written as ANSI CSV, regardless of the source encoding - re-run through the File Encoding And BOM Fixer script if the destination software needs Unicode. - The file is read twice: once to count rows for the numbering width, once to write the chunks. A very large file takes proportionally longer because of the extra pass, but never holds more than one line in memory at a time. - Rows are copied verbatim with no column awareness, so a source with inconsistent column counts between rows splits exactly as inconsistently as it started. - The file must sit under the terminal's Files sandbox; files outside it are not reachable without the common-folder flag, which this script does not use.
Script · MT4 · v1.0 · Free
About Large File Splitter By Rows
Large File Splitter By Rows is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Input file, Rows per chunk and Has header. MQL source code included.
Files in the download: LargeFileSplitterByRows.ex4, LargeFileSplitterByRows.mq4, LargeFileSplitterByRows.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Input file | Input file, relative to MQL4\Files | |
| Rows per chunk | 100000 | Data rows per chunk (header not counted) |
| Has header | true | First line is a header, repeated in every chunk |
| Output prefix | Output name prefix (blank = input base name) | |
| Unicode source | false | Source file is UTF-16LE instead of ANSI |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code