Jump to content
ichavarria

Import text from csv (X,Y,Code)

Recommended Posts

ichavarria

Hi, i'm want to import the code (or description) from csv file (X,Y,Code) on the coordinates of each point.

 

I can do it in excel, but i'm looking for a easy way.

 

Captura.jpg

 

Captura1.jpg

 

The layer could be current, height 2, and rotation 0. I can change this properties later, so no problem about it.

 

 

Please excuse my limited English, corrections are welcome.

 

 

Many thanks in advance.

Share this post


Link to post
Share on other sites
Lee Mac

Very quickly written:

(defun c:txtin ( / csv des ins lst str )
   (if (and (setq csv (getfiled "Select CSV File" "" "*" 0))
            (setq des (open csv "r"))
       )
       (progn
           (while (setq str (read-line des))
               (while (vl-string-position 44 str)
                   (setq str (vl-string-subst "\"\"" "," str))
               )
               (if (and (setq  lst (read (strcat "(\"" str "\")")))
                        (setq  ins (mapcar 'distof lst '(2 2)))
                        (caddr lst)
                   )
                   (entmake (list '(0 . "TEXT") '(40 . 2.0) (cons 10 ins) (cons 1 (caddr lst))))
               )
           )
           (close des)
       )
   )
   (princ)
)

Share this post


Link to post
Share on other sites
ichavarria

Thank you very much Lee Mac :)

 

It is exactly what I had been long looking for. Many thanks for your help.

Share this post


Link to post
Share on other sites
Lee Mac

You're welcome - glad it helps.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...