乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: ynotrobits

[编程交流] Use read-line to extract comma

[复制链接]

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 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 ?
回复

使用道具 举报

20

主题

95

帖子

75

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 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
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 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 of  the excel file ?
 
I may need to write a function to do instead of these fore-said functions ( if I could ) .
回复

使用道具 举报

20

主题

95

帖子

75

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 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.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 23:37:08 | 显示全部楼层
This is more than enough I guess .
 
  1. (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 ......))             )     ))
回复

使用道具 举报

20

主题

95

帖子

75

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 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?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 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 ?
回复

使用道具 举报

20

主题

95

帖子

75

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 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?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 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 .
回复

使用道具 举报

20

主题

95

帖子

75

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 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.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-11 03:13 , Processed in 1.558613 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表