Split large file by line count not predfined size

Hi, I have a text file with say 50000+ lines (CSV format) and I would like to split this into smaller files of 1000 records with the last file most likely having < 1000 lines. I know DOPUS has the SPLIT tool but that's only allowing you to split by a particular size and not lines.

Many thanks

In Opus a script could do this. But you might be faster with tools already available:

https://www.google.com/search?q=split+text+file+by+line+count

It could be done using scripting.

Would you want to duplicate the first row (often a list of heading names) at the start of each file as well?

A quick example which would just copy all the lines from one file to another:

    var fso = new ActiveXObject("Scripting.FileSystemObject");

    var inFile = fso.OpenTextFile(input_file_path);
    var outFile = fso.CreateTextFile(output_file_path, true);

    while (!inFile.AtEndOfStream)
    {
        outFile.WriteLine( inFile.ReadLine() );
    }

    inFile.Close();
    outFile.Close();

A good spot there Leo, yes I would like the first row copied to each new file! Thanks