Jump to content
Leinad

Help to open cvs after saving it

Recommended Posts

Leinad

Hi, i have a problem opening the csv automatically,

 

i modified tharwat code but its not open the csv after saving the csv in other folder location..

 

(defun c:C2XLS  (/ sel f o l)
 (princ "\n Select All texts :")
 (if (and (setq sel (ssget '((0 . "TEXT"))))
          (setq f (getfiled "Save as to csv format "
                            (getvar 'DWGPREFIX)
                            "CSV"
                            1))
          (setq o (open f "w")) ; this line not open
          )
   (progn
     ((lambda (x / sn e)
        (while (setq sn (ssname sel (setq x (1+ x))))
          (setq l
                 (cons (list (cdr (assoc 10 (setq e (entget sn))))
                             (cdr (assoc 1 e)))
                       l))
          )
        )
       -1)
     (setq l
            (vl-sort l
                     '(lambda (q p) (< (cadr (car q)) (cadr (car p))))))
     (write-line "CHAINAGE,EASTING,NORTHING" o)
     (mapcar '(lambda (v)
                (write-line
                  (strcat (cadr v)
                          ","
                          (rtos (caar v) 2)
                          ","
                          (rtos (cadar v) 2)
                          ","
                          (rtos (caddar v) 2))
                  o))
             l)
     (close o)
     )
   )
 (princ)
 )

Share this post


Link to post
Share on other sites
BIGAL

What does the csv look like ?

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...