Jump to content

Write multiple CSV files


gsc

Recommended Posts

Hi,

 

In my LISP routine 4 (large) lists needs to be written to 4 CSV files.
Is it possible to run 4 write actions at the same time?

If this is not possible how do I run them after each other, where one write action is finished before the next starts?

Link to comment
Share on other sites

Try it and see - best way to learn what works!

 

Remembering to call each a unique name and reference within the LISP

 

 

 

By way of example, from Lee Mac - commenting out some of the nice stuff he puts in

 

(defun c:writetextfile ( / des txt ) ;; Define function, declare local variables
;;  (if (setq txt (getfiled "Create Text File" "" "txt" 1)) ;; Prompt user for filename/filepath
;;    (progn
      (setq txt1 (getfiled "Create Text File" "" "txt" 1))
      (setq txt2 (getfiled "Create Text File" "" "txt" 1))
      (setq txt3 (getfiled "Create Text File" "" "txt" 1))
;;      (if (setq des (open txt "w")) ;; Attempt to create text file with given filename/filepath
        (progn ;; Evaluate the enclose expressions as the 'then' expression for the IF statement

           (setq des1 (open txt1 "w")) ;; Attempt to create text file with given filename/filepath
           (setq des2 (open txt2 "w")) ;; Attempt to create text file with given filename/filepath
           (setq des3 (open txt3 "w")) ;; Attempt to create text file with given filename/filepath

           (write-line "This is a test 1." des1) ;; Write line of text to text file
           (write-line "This is a test 2." des2) ;; Write line of text to text file
           (write-line "This is a test 3." des3) ;; Write line of text to text file

           (close des3) ;; Close file descriptor
           (close des2) ;; Close file descriptor
           (close des1) ;; Close file descriptor

         ) ;; end PROGN
;;           (princ "\nUnable to create text file.") ;; Else the text file could not be created
;;       ) ;; end IF
;;       (princ "\n*Cancel*") ;; Else the user pressed Cancel
;;    ) ;; end PROGM
;;  ) ;; end IF
   (princ) ;; Suppress the return of the last evaluated expression
) ;; end DEFUN

 

Edited by Steven P
  • Like 1
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...