3 Replies Latest reply: May 15, 2014 10:06 AM by Data Kruncher RSS

    Export multiple database files at once

    Tia Daems

      I am a brand new user and am using Monarch Pro v 10.5. I would like to open multiple excel files at once and apply the same model, then export all the files (at once) to a delimited file format.  I do need to keep the files seperated, with each txt export file name the same as the import excel file name.  How can this be achieved?

        • Export multiple database files at once
          Data Kruncher

          Hi Tia, and welcome to the forum.

           

          Unfortunately you've encountered a bit of a Catch-22 situation there: Monarch will only allow you to simultaneously open multiple files using the Open Database approach if the input files are delimited text. Ironic, huh?

           

          I'd be tempted to write a VBS script to handle your task. Which Excel file type are you using: .xls or .xlsx, or something else?

           

          There may similar examples of such a script in this forum. I'll see what I can find. Odds are though that it would be faster to just start coding.

           

          Kruncher

            • Export multiple database files at once
              Tia Daems

              Kruncher,

               

              Thank you for the welcome and also the VERY quick answer! Oh goodness. I don't know VBS.   I am using .xls files as input. Any further information you can provide would be most appreciative!

               

              Tia

                • Export multiple database files at once
                  Data Kruncher

                  After some experimentation, I finally got the syntax right for a little batch file to accomplish this challenge.

                   

                  First, you need both a model and a project file to handle one of the Excel files.

                   

                  @echo off

                  c:

                  cd \test

                  for %%i in (*.xls) do Call :DoMonarch "%%i"

                   

                  GOTO :EOF

                   

                  :DoMonarch

                   

                  ("C:\Program Files\Monarch\Program\Monarch.exe" /prj:"C:\test\project.xprj" /datasource:"%1" /exp:"%1".csv)

                  GOTO :EOF

                  /CODE

                   

                  Copy this to Notepad, revising the drive letter and folder names and the project name as necessary and save it as "XLStoCSV.bat".

                   

                  The end result of running the batch file, as shown above, is that all of the .xls files in C:\test will be converted to .csv files.

                   

                  If the folder contained three files named Export1.xls Export2.xls and Export3.xls then the folder will contain Export1.xls.csv Export2.xls.csv and Export3.xls.csv

                   

                  Windows won't care about the .xls in the middle of the .csv file names.

                   

                  HTH,

                  Kruncher