I'd actually use a combination of the techniques discussed here, using RedirectOutput() to eliminate the need to Open(), Write(), and Close() all the individual output files.
Code:
$SourceFile = 'file.csv'
$Counter = 1
Del 'c:\temp\subfile.????.csv' ; delete all output files
If $Open(5, $SourceFile, 2) ; open the source file
$Line = ReadLine(5) ; read a line
While Not @ERROR ; read until EndOfFile error
; create an index - 0000 to 9999 - to determine which group of 1000 we're in
$Index = Right('0000' + CStr(Int($Counter / 1000)), 4)
; Define the output file based on a base file name/path, the index, and the extension
$OutFile = 'c:\temp\subfile.' + $Index + '.csv'
; print the line, redirecting output to the current outfile
$ = RedirectOutput($OutFile)
$Line ?
$ = RedirectOutput('')
; Read the next line and increment the counter
$Line = ReadFile(5)
$Counter = $Counter + 1
Loop
$ = Close(5)
Else
? 'Error opening ' $SourceFile ' - Aborting!' ? ?
Exit 1
EndIf
Glenn
PS - this is an example - you'll want to add some error checking, and there's more efficient ways to handle the RedirectOutput. One thought - save the previous OutFile, and close/reopen the RedirectOutput only when it changes.
_________________________
Actually I
am a Rocket Scientist!