I have searched here, and Augi for a string parser that will handle quoted delimiters. I found routines by Peter Jamtgaard, and John Uhden, but nothing that will handle fields with quoted delimiters thus:
(csvstringtolist "Field 1, Field 2, Field 3, \"Field 4, This is\" still field 4, Field5" ",")
Everything I've found, including my own standby routine, returns 6 fields, rather than 5.
Here's my standby routine:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Routine: Split ;;;
;;; Purpose: Parse a delimited string ;;;
;;; Arguments: First - a delimited string ;;;
;;; Second - the delimiting character ;;;
;;; Returns: A list of strings, consecutive delimiters produce blank fields ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun split ( ;parse a string into a list
str ;string to parse
delim ;delimiter
/ ;end of formal arguments
rtlist i
) ;end of local variable list
(while (setq i (vl-string-search delim str))
(setq
rtlist (cons (substr str 1 i) rtlist)
str (substr str (+ 2 i))
)
)
(if (= str "")
(setq rtlist (cons "" rtlist))
(setq rtlist (cons str rtlist))
)
(reverse rtlist)
)