Michael Richards Posted April 22 Share Posted April 22 (defun PARSEFILE () (setq NOTEFILE (open LIB1 "rt")) (if NOTEFILE (progn (princ "\nReading note file. ") (setq WORKINGNOTE nil) (while (setq NEWLINE (read-line NOTEFILE)) (progn ; ;delete trailing spaces ; (while (and (> (strlen NEWLINE) 0) (= (substr NEWLINE (strlen NEWLINE)) " ")) (setq NEWLINE (substr NEWLINE 1 (1- (strlen NEWLINE)))) );end while (if (/= NEWLINE "") (progn ; ;find keynote number ; (setq I 1) (while (and (< I (strlen NEWLINE)) (/= (substr NEWLINE I 1) " ")) (setq I (+ I 1)) );end while (if (> I 1) (progn (setq WORKINGNOTE (substr NEWLINE 1 (1- I))) (setq WORKINGNOTE (strcase WORKINGNOTE)) (if (not (member WORKINGNOTE IDlist)) (setq WORKINGNOTE nil) );end if (setq NEWLINE (substr NEWLINE I)) );end progn );end if ; ;delete leading spaces ; (setq I 1) (while (= (substr NEWLINE I 1) " ") (setq I (+ I 1)) );end while (setq NEWLINE (substr NEWLINE I)) );end progn );end if (if WORKINGNOTE (progn (setq FOUND "F") (setq TEMPLIST NOTELIST) (setq NOTELIST nil) (foreach THISNOTE TEMPLIST (progn (if (and (= FOUND "F") (= WORKINGNOTE (car THISNOTE))) (progn (setq THISNOTE (append THISNOTE (list NEWLINE))) (setq FOUND "T") );end progn );end if (setq NOTELIST (cons THISNOTE NOTELIST)) );end progn );end foreach (setq NOTELIST (reverse NOTELIST)) (setq TEMPLIST nil) );end progn );end if );end progn );end while (close NOTEFILE) ; ;delete trailing lines ; (setq TEMPLIST NOTELIST) (setq NOTELIST nil) (foreach THISNOTE TEMPLIST (progn (setq THISNOTE (reverse THISNOTE)) (while (= (car THISNOTE) "") (setq THISNOTE (cdr THISNOTE)) );end while (setq THISNOTE (reverse THISNOTE)) (setq NOTELIST (cons THISNOTE NOTELIST)) );end progn );end foreach (setq NOTELIST (reverse NOTELIST)) (setq TEMPLIST nil) (princ " Done.") );end progn );end if );end defun PARSEFILE This is a small part of a larger routine that was used with wordperfect ascii dos txt files and I am having difficulty changing this function to read and use a csv file Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 22 Share Posted April 22 (edited) Have a look at this posted yesterday. Go to end of posts, has read file and make a list of the file. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/progress-bar-in-lisp-code/td-p/12722940 Edited April 22 by BIGAL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.