| | |
Windows batch script
![]() |
You're using bash in cygwin but saying a windows batch file would be preferable but exploring adding coreutils... what language can this be in? I'm afraid you're out of luck when it comes to a .BAT file unless you can hunt down those guys who made as400 batch files... they did things I didn't know DOS was capable of.
Is a bash script an acceptable solution?
Is a bash script an acceptable solution?
•
•
Join Date: Jun 2009
Posts: 9
Reputation:
Solved Threads: 0
I came up with a vb script that reads in the data but doesn't stop at the blank line of the input. Also every thing is put into the first cell of each row.
The typical line will have the following: What is in the () would be the in the 2nd cell of each row of the csv file, I want to eleminate the dashes anf the words "Functional Aggregate". The other issue is that some rows may have the "Functional Aggregate" and the AAAAA026 switched around.
AAAUSA-0057 (AAAA CCCC) - AAAAA026 - Functional Aggregate,100.00,0.00,0.00,good
The output needs to look like the following:
AAAUSA-0057" "AAAA CCCC" "AAAAA026" "100.00" "0.00" "0.00"
this would be cells A1 - A6 and so on.
This is the VBS code I have so far.
Const xlGeneralFormat = 1
Const xlNormal = -4143
Const xlLastCell = 5
Dim sFiNa
Dim oFS
Dim oExcel
Dim oWBook
Dim sTmp
' Text file to work with
sFiNa = "FunBusAgg"
Set oFS = CreateObject( "Scripting.FileSystemObject" )
sFiNa = oFS.GetAbsolutePathName( sFiNa )
Set oExcel = CreateObject( "Excel.Application")
oExcel.Visible = True
' oExcel.Whatever = False
sTmp = "Working with MS Excel Vers. " & oExcel.Version _
& " (" & oExcel.Workbooks.Count & " Workbooks)"
oExcel.Workbooks.Open sFiNa, xlGeneralFormat
Set oWBook = oExcel.Workbooks( 1 )
' oExcel.Range(oExcel.cells(1,1),oExcel.cells(100,1)).Select
oExcel.Range( oExcel.cells( 1, 1 ) _
, oExcel.cells( oWBook.Sheets( 1 ).UsedRange.SpecialCells( xlLastCell ).Row , 1 ) _
).Select
oExcel.Selection.TextToColumns oExcel.Range("A1"), xlGeneralFormat
' save as XLS
oWBook.SaveAs sFiNa + ".csv", xlNormal
' oWBook.Close
' oExcel.Quit
The typical line will have the following: What is in the () would be the in the 2nd cell of each row of the csv file, I want to eleminate the dashes anf the words "Functional Aggregate". The other issue is that some rows may have the "Functional Aggregate" and the AAAAA026 switched around.
AAAUSA-0057 (AAAA CCCC) - AAAAA026 - Functional Aggregate,100.00,0.00,0.00,good
The output needs to look like the following:
AAAUSA-0057" "AAAA CCCC" "AAAAA026" "100.00" "0.00" "0.00"
this would be cells A1 - A6 and so on.
This is the VBS code I have so far.
Const xlGeneralFormat = 1
Const xlNormal = -4143
Const xlLastCell = 5
Dim sFiNa
Dim oFS
Dim oExcel
Dim oWBook
Dim sTmp
' Text file to work with
sFiNa = "FunBusAgg"
Set oFS = CreateObject( "Scripting.FileSystemObject" )
sFiNa = oFS.GetAbsolutePathName( sFiNa )
Set oExcel = CreateObject( "Excel.Application")
oExcel.Visible = True
' oExcel.Whatever = False
sTmp = "Working with MS Excel Vers. " & oExcel.Version _
& " (" & oExcel.Workbooks.Count & " Workbooks)"
oExcel.Workbooks.Open sFiNa, xlGeneralFormat
Set oWBook = oExcel.Workbooks( 1 )
' oExcel.Range(oExcel.cells(1,1),oExcel.cells(100,1)).Select
oExcel.Range( oExcel.cells( 1, 1 ) _
, oExcel.cells( oWBook.Sheets( 1 ).UsedRange.SpecialCells( xlLastCell ).Row , 1 ) _
).Select
oExcel.Selection.TextToColumns oExcel.Range("A1"), xlGeneralFormat
' save as XLS
oWBook.SaveAs sFiNa + ".csv", xlNormal
' oWBook.Close
' oExcel.Quit
Last edited by codester; Aug 23rd, 2009 at 6:40 pm.
![]() |
Similar Threads
- Delete a directory using batch script (Legacy and Other Languages)
- Changing a background in a batch script (Windows NT / 2000 / XP)
- Mysql Backup Batch Script (MySQL)
- Closing batch script after .exe is called (Windows NT / 2000 / XP)
- Batch Script - Error 7901??? (Windows NT / 2000 / XP)
- Problem with variables in Windows shell script (Windows NT / 2000 / XP)
Other Threads in the Shell Scripting Forum
- Previous Thread: EventHandler using Shell script
- Next Thread: how to prevent user close window during script execution?
| Thread Tools | Search this Thread |






