Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ion my script output i have multiple cvs files

Posted on 2016-08-09
3
Medium Priority
?
63 Views
Last Modified: 2016-08-09
I have one script that generates about 5 cvs files. Is there a way i can open the main one and have it put the other cvs files in their own tabs?
0
Comment
Question by:lolaferrari
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 57

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 41748821
Would I be correct in assuming that you want the CSV files opened in Excel?

~bp
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 41748877
Here is a fairly simple VBS script (building off this previous question) that merges a specified list of CSV files into a single Excel workbook, as tabs.  Save as a VBS file, update the file paths as needed, and run from a BAT or command line as follows:

cscript EE28962338.vbs

' Some constants from Excel object model
Const cExcelXLS = 56
Const cExcelXLSX = 51

' Set up filesystem object for usage
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Define paths to CSV and Excel file paths
sNewFile = objFSO.GetAbsolutePathname("all.xlsx")
aCsvFiles = Array(objFSO.GetAbsolutePathname("file1.csv"), _
                  objFSO.GetAbsolutePathname("file2.csv"), _
                  objFSO.GetAbsolutePathname("file3.csv"), _
                  objFSO.GetAbsolutePathname("file4.csv"), _
                  objFSO.GetAbsolutePathname("file5.csv"))

' Instantiate the Excel application, but don't show it
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = False
oExcel.DisplayAlerts = False

' Add each CSV file as a sheet to a new Excel workbook
For i = 0 to UBound(aCsvFiles)
   If i = 0 Then
      Set oNew = oExcel.Workbooks.Open(aCsvFiles(i))
   Else
      Set oAdd = oExcel.Workbooks.Open(aCsvFiles(i))
      oAdd.Sheets(1).Move , oNew.Sheets(i)
   End If
Next

' Save merged result as an Excel file
oNew.SaveAs sNewFile, cExcelXLSX
oNew.Close

' Shut down Excel
oExcel.Quit

Open in new window

~bp
0
 

Author Closing Comment

by:lolaferrari
ID: 41748930
Thank you very much!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question