csplit (for Windows and UNIX)
Installation of csplit (Windows only)
A variety of simple utilities for text manipulation is standard with most UNIX releases. These useful utilities are also available for Windows, but, alas, they have retained the non-intuitive installation routines and command line interface from UNIX. Here is a step-by-step instruction for installation in Windows 9x/ME/2000/XP:
- Make sure that Internet Explorer 4.0 or later is installed.
- Download and run libiconv-1.8-1-bin.exe.
- Download and run libintl-0.11.5-2-bin.exe.
- Download the files highlighted in pink on the sourceforge page.
- Unzip (e.g., by using Winzip) the latter files into the directory
that
contains the GNUWin files on your harddisk. Typical locations of this directory are:
- C:\Program Files\GnuWin32\
- D:\Program Files\GnuWin32\
- C:\Programme\GnuWin32\
- D:\Programme\GnuWin32\
You are done! You have installed GNUWin32 Text Utilities. Check out their manual to make full use of these utilities, which you can unfortunately only access by using the "Start -> Run" interface in Windows.
Usage of csplit
Here is an example on how to use the csplit utility. Suppose, you want to split a LEXIS/NEXIS result file into set of subfiles, each of which contain a single article record. This is, what you need to do:
- Download the result file as "ASCII file". If you downloaded the default RTF-File, use your word processor (e.g., Word, WordPerfect, etc.) to convert the file into ASCII by saving it as "text only (.txt)".
- Check how many records are in the file. Let us call that number n.
- Open the file in a word processor (or a text editor) and replace the number denoting the total number of documents in the record delimiter (e.g., "1 of 864 Documents") by a string that will not exist in any of the articles, for instance, "qq", and the number itself. That is, in the current example you would replace "864 Documents" by "qq864 Documents". (You need to perform this replacement, because otherwise you run the risk of chopping up records that by chance contain the total number of records in the contents of the record.)
- Run
"C:\Program Files\GnuWin32\bin\csplit.exe" C:\split\search.txt /qqn/ {*}
in the "Start -> Run" box, where C:\split\results.txt is the full path of the LEXIS/NEXIS file you want to split and n is the number of articles in the result file (or any other string that might serve as a delimiter for records).
NB: Make sure that neither the file path or the file name of the file you want to split itself contains any spaces! Also, use spaces and quotation marks exactly as they are used in the command line above.
UNIX uses the following command line:
csplit.exe C:\split\search.txt /qqn/ {*}
- You will find the separate files in the folder, into which csplit.exe was installed (e.g., "C:\Program Files\GnuWin32\bin\"). Their names will consist of xx and a number. Use RenameFiles to give them more sensible names.