Jump to content

Help to open cvs after saving it


Leinad

Recommended Posts

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

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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