尝试以下操作:
“out”将是您的列表列表
- (defun c:readmycsv (/ fl out)
- ;; String to List - Lee Mac
- ;; Separates a string using a given delimiter
- ;; str - [str] String to process
- ;; del - [str] Delimiter by which to separate the string
- ;; Returns: [lst] List of strings
- (defun lm:str->lst (str del / pos)
- (if (setq pos (vl-string-search del str))
- (cons (substr str 1 pos) (lm:str->lst (substr str (+ pos 1 (strlen del))) del))
- (list str)
- )
- )
- (if (setq fl (open "C:\\Users\\ggleason\\Documents\\CAD\\AutoCAD\\Lisp\\Book1.csv" "r"))
- (progn (while (setq fil (read-line fl)) (setq out (cons (lm:str->lst fil ",") out))) (close fl))
- )
- (reverse out)
- )
|