Tharwat 发表于 2022-7-5 23:25:28

Just show an example of what you are after and then to upload aa example of your csv file .
 
How would the return value of read-line function is it reads tow columns and more ? I mean what is the separator between strings ? is it comma or semicolon ?

jmerch 发表于 2022-7-5 23:28:18

Attached is a sample csv file. The current separator is a comma. I tried the (nth 0 list) method with no progress either. I changed the date format thinking the slashes had something to do with it, but that's not the case either.
 
The entire code is essentially what I've posted minus some typical error traps.
 
Test.csv

Tharwat 发表于 2022-7-5 23:30:58

Okay , now forget about the two third parties and tell me what you are trying to do with the contents ofthe excel file ?
 
I may need to write a function to do instead of these fore-said functions ( if I could ) .

jmerch 发表于 2022-7-5 23:34:41

I understand. I'm trying to read the data in the first column (aside from the header). The closest comparison I can suggest is a filter. I need to filter the drawing for an attribute that is equal to the data in that cell, and so on.
 
My LISP works fine If the csv file just had the one column of data, no problems.

Tharwat 发表于 2022-7-5 23:37:08

This is more than enough I guess .
 

(while (setq str (read-line f))   (if (setq p (vl-string-search "," str 0))       (cond ((eq (setq str (substr str 1 p)) "test1") (Do something ......))             ((eq str "test2") (Do somthing ......))             )   ))

jmerch 发表于 2022-7-5 23:42:12

So you're putting conditions in there based on actual text values, but it needs to vary to whatever str is. Does that make sense? For each value in the csv file, the LISP should filter it, then do something with it. Then move to the next value, same thing, and so on. Am I complicating it or am I not understanding what you're doing?

Tharwat 发表于 2022-7-5 23:44:23

I am walking step by step with you cause I do not know why you keep your aim of the routine hidden , but I am still standing
 
If you have so many string to check with the one from the excel file , you can use member function to check if a string is a member in that list . What do you think ?

jmerch 发表于 2022-7-5 23:45:44

I apologize if my intent seems hidden, it's due to the third party commands. Without you knowing them, it's pointless to explain them which is why I've been comparing them to basic CAD commands, such as filter.
 
The data in the csv file will change constantly. This LISP is to look at the file, and for each value in the cell of the first column it needs to search the drawing (filter) and when the filter has those objects selected, a script will be ran on them. Then the next value down, same thing, and so on until no more values in excel. I don't need it to search the drawing first to see if the value is present, I know it will be present.
 
The LISP worked fine when it was just a single column csv, but we had to add the second column so my issue is just trying to weed out the first column values and continue on.
 
Did I make it muddier?

Tharwat 发表于 2022-7-5 23:51:33

 
You can make a list of the strings from the Excel file the after that you can check for every string in list .
 
The values you put in the excel file are completely different than what you are after , right ? anyway that is your way and this is what I can offer up to point that I reached your aim of the codes .

jmerch 发表于 2022-7-5 23:54:44

 
Initially that's what I was trying to do...(read-file f) will return "1,6/21/2014" for example. I just need the LISP to see the "1". I initially tried removing the comma's per your original code on this post to create a list, then was going to try (car list). Then I saw you cleaned it up a bit and thought I could do that skipping the removing of the comma and just telling LISP to look for the first value. That's where we're stuck.
 
 
The values in excel are what I need to store and use later in the LISP, doing it for each line in the excel file.
 
Thanks for your efforts.
页: 1 [2]
查看完整版本: Use read-line to extract comma