reza Posted February 25, 2018 Share Posted February 25, 2018 Hi everyone: I have a list like this: (" 1 -30.0000 1158.3733 1" " 25 -29.7469 1158.5000 1" " 138 -29.3861 1158.6920 1") How can I convert it to the following? ("-30.0000 1158.3733" "-29.7469 1158.5000" "-29.3861 1158.6920") Thanks if you guide me Quote Link to comment Share on other sites More sharing options...
pBe Posted February 25, 2018 Share Posted February 25, 2018 I think the list came from an external file [csv/txt]., What you need to do is separate the individual items before passing the values to a list. Show us the code that you use to build the list and we'll pick up from there. Quote Link to comment Share on other sites More sharing options...
reza Posted February 25, 2018 Author Share Posted February 25, 2018 Hi thanks for reply This code 1deltxt.lsp to pars export data file. List to File.lsp Quote Link to comment Share on other sites More sharing options...
reza Posted February 25, 2018 Author Share Posted February 25, 2018 text files are: 1-export list.txt 2-Chanage.txt Quote Link to comment Share on other sites More sharing options...
pBe Posted February 25, 2018 Share Posted February 25, 2018 Ok, hang on... Quote Link to comment Share on other sites More sharing options...
reza Posted February 25, 2018 Author Share Posted February 25, 2018 thanks a lot sure Quote Link to comment Share on other sites More sharing options...
pBe Posted February 25, 2018 Share Posted February 25, 2018 thanks a lotsure What are you planning to do with the converted list? Do you need this a point list? converted to floating point rather than strings? did you write those code yourself? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 25, 2018 Share Posted February 25, 2018 I do lots of things with points as a Civil engineer and like Pbe what is the bottom line of the desired ouput. It is feasible to pull apart the txt files from scratch and make your list of points directly. Quote Link to comment Share on other sites More sharing options...
reza Posted February 25, 2018 Author Share Posted February 25, 2018 I need this list to send use in a program called "CSDP" But this question is important to me in this regard How to solve this problem with the Lisp or Visual Lisp instructions Regardless of what software is used in this information. I wrote the first application using a post in one of the forums. And the second program using the functions available in Lisp. Quote Link to comment Share on other sites More sharing options...
pBe Posted February 25, 2018 Share Posted February 25, 2018 From a recent thread Modified for your requirement (defun _csv->lst ( str / pos) [color="blue"](setq str (vl-string-left-trim " " str)) [/color] (if (setq pos (vl-string-position [color="blue"]32[/color] str)) (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2)) [color="blue"]32[/color] )) (list str) ) ) resulting to ("1" "-30.0000" "1158.3733" "1") ("2" "-29.7469" "1158.5000" "1") ("3" "-29.3861" "1158.6920" "1") .... (strcat (cadr x) " " (caddr x)) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 26, 2018 Share Posted February 26, 2018 Starting with the original text file makes more sense to me and just save a new text file with exactly what you want. Dont make un-necessary lists. The text file has patterns so its not that hard. This coding could be written in any programming language even write it in excel it has VBA built in. What is "CSDP" 1 read line look for "Station" store line 2 continue reading look for "vertex" 3 read sequence of lines when blank is end of xsection. Repeat reading lines with steps 1 2 3. Last word opened in Excel and just copied and pasted to achieve result required no sweaty brow trying to write code just import using space as delimiter. Again make a macro to delete lines not required. Quote Link to comment Share on other sites More sharing options...
reza Posted February 26, 2018 Author Share Posted February 26, 2018 Hi pBe Thank you Your advice helped me solve my problem very much Sincerely Reza Monemi Quote Link to comment Share on other sites More sharing options...
reza Posted February 26, 2018 Author Share Posted February 26, 2018 Hi BIGAL thank you for reply I've already used your ideas in other posts. To get to know "CSDP", go to the following address: http://www.csdpworld.com/en/home.asp Quote Link to comment Share on other sites More sharing options...
pBe Posted February 26, 2018 Share Posted February 26, 2018 Hi pBeThank you Your advice helped me solve my problem very much Good for you, Like what BIGAL said, the process can be streamlined by starting with the original text file. Have fun coding. pBe Quote Link to comment Share on other sites More sharing options...
reza Posted February 27, 2018 Author Share Posted February 27, 2018 :D:D:D:D:D :):) :shock: Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 27, 2018 Share Posted February 27, 2018 The link did not explain what your trying to do. Quote Link to comment Share on other sites More sharing options...
reza Posted February 27, 2018 Author Share Posted February 27, 2018 Please refer to the links for more information 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.