In this LISP you are creating a CSV file, comma separated data, which as far as LISP is concerned is just a text file - and knowing this helps you along the way/
To modify or create a text file the LISP uses the command "write-line" to well, write each line of the text / CSV file
For example, your header row is created using this:
(write-line "HANDLE,LENGTH,LAYER,X,Y,Z" F)
You could modify that line to be:
(write-line "HANDLE,LENGTH" F)
So look through the rest of the code for all the "write-lines"
These all have the format: (copying the line before as well)
(setq tmp (strcat txt (rtos (car pnt) 2) "," (rtos (cadr pnt) 2) ",0.0"))
(write-line tmp f)
"write-line tmp f" writes the variable tmp to the text file. Looking at tmp, strcat is like excel concatenate, joins text strings together, so tmp is the variable txt, and some stuff done to variable pnt - which I guess is 'point'
So go back up the code a bit, txt is defined once:
(setq txt (strcat han "," len "," lyr ","))
So what to do.....
Modify the header row as above. "Handle,Length"
and just before the (write-line tmp f) line just put (setq tmp txt), noting I also comment out (add ;;) the original setq tmp line - just so you can go back to the original if needed
;; (setq tmp (strcat txt (rtos (car pnt) 2) "," (rtos (cadr pnt) 2) ",0.0"))
(setq tmp txt)
(write-line tmp f)
Right now adding in the count.
You'll want to set a counter somewhere in this. the code has a 'repeat' command, perhaps before then put in a line such as
(setq acount 0)
Then the first line after repeat increment this as you want
(setq acount (+ acount 10))
then work out how to modify the header to show the acount (look earlier in this answer), and also how to add this to the correct part of the variable tmp (perhaps looking at the strcat line above for a hint)
see how that works and ask again if you need more info.... long weekend break here so no CAD nut I can give you hints rather than a finished LISP