Split a text file with HTML5
It may happen to end up with a file (Fig 1) too big, that we want to split in smaller pieces. For example, a data file that we then want to upload in SAP, but that is too big in its present state.
In order to send data in several picks, I propose you an HTML5 tool (Fig 2)[1], with local execution (on your computer) only, which will split your text file locally and keep your data safe.
Make sure you have your text file (Fig 1), specify number of header lines to split at the beginning of the file and to repeat on each part – or specify 0 if your file has no header lines – and the number of lines to get in each split.
Choose then the easiest way for you to provide the file, by selecting it on your computer, or by dragging and dropping it in the corresponding area.
File treatment may be long depending on your file size and your computer power.
You will then be able to get in the lower part of the results page (Fig 3) different parts of the file splitted. Right click on each part and select “Save link target as…”.
Be careful, as the application[1] was built using HTML5, it may not work if you are using an old web browser (Fig 4) which do not manage current web standards. Do not hesitate to get Mozilla Firefox[2] or Google Chrome[3] for example.
Technically, files are read locally[4], using File API[5], and then processed thanks to FileSystem[6]. A download link[7] is proposed. FIles are generated locally inbetween[8], download links are proposed using DOM modifications[9]. The interface is a simple CSS3 styled[10] form.
Hyperlink
Links and credits
- [1] – Split a text file with HTML5 – Yoann Bierling, International Consultant – textfilesplit
- [2] – Download and install Mozilla Firefox web browser – http://getfirefox.com
- [3] – Download and install Google Chrome web browser – http://www.google.com/chrome
- [4] – Reading local files in Javascript – HTML5 Rocks (en) – http://www.html5rocks.com
- [6] – Exploring the FileSystem APIs – HTML5 Rocks (en) – http://www.html5rocks.com
- [7] – Downloading resources in HTML5: a[download] – HTML5Rocks Updates (en) – http://updates.html5rocks.com
- [8] – Using HTML5/Javascript to generate and save a file – Stack Overflow (en) – http://stackoverflow.com
- [9] – FileReader – Document Object Mode (DOM) | MDN (en) – https://developer.mozilla.org
- [10] – Clean and Stylish CSS3 Form | Gazpo.com (en) – http://gazpo.com