Hudson Posted October 20, 2009 Share Posted October 20, 2009 Good morning, Now that I can write my comma delimited file I'd like to load it. I've searched around, but haven't turned anything up that readily makes sense of what I want.. which surprises me. Right now my delimiter is a , with no space on either side.. does that make it easier or harder? I know there is some sort of command for reading a string character by character.. but haven't located it as of yet. Thanks for any and all help, Andrew Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 20, 2009 Share Posted October 20, 2009 What is the final form you wish for the output the string is being converted to: point listplain listdotted pairanother stringsomething that can be evaluated Each has to be dealt with differently. -David Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 20, 2009 Share Posted October 20, 2009 Mr. Gile was nice enough to post these one time... ;;; STR2LST ;;; Transforms a string with separator into a list of strings ;;; Author: Gile ;;; Arguments ;;; str = the string ;;; sep = the separator pattern (defun str2lst (str sep / pos) (if (setq pos (vl-string-search sep str)) (cons (substr str 1 pos) (str2lst (substr str (+ (strlen sep) pos 1)) sep) ) (list str) ) ) ;;; lST2STR ;;; Returns a string which is the concatenation of a list and a separator ;;; Author: Gile ;;; Arguments ;;; str = the string ;;; sep = the separator pattern (defun lst2str (lst sep) (if (cadr lst) (strcat (vl-princ-to-string (car lst)) sep (lst2str (cdr lst) sep) ) (vl-princ-to-string (car lst)) ) ) Quote Link to comment Share on other sites More sharing options...
Hudson Posted October 20, 2009 Author Share Posted October 20, 2009 Alan thanks! That looks like exactly what I want, or close enough to it. I want to read a line and turn it into a list of strings which will be a list of list of strings. Andrew Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 20, 2009 Share Posted October 20, 2009 Alan thanks! That looks like exactly what I want, or close enough to it. I want to read a line and turn it into a list of strings which will be a list of list of strings. Andrew You can do exactly that with what I've posted. (str2lst STRING ",") 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.