WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Arrays
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Transpose Array

 Keywords: Transpose Array Flip Rows Columns Excel VB WB 

#DefineFunction ArrayTranspose(arrA)
    If ArrInfo(arrA, 0) != 2
       Pause( 'ArrayTranspose','Must Pass a 2 Dimensional Array.')
       Return 0
    EndIf
    nRows = ArrInfo(arrA, 1)
    nCols = ArrInfo(arrA, 2)
    arrTempArray = ArrDimension( nCols, nRows )
    For R = 0 To  nRows-1
        For C = 0 To nCols-1
            arrTempArray[C, R] = arrA[R, C]
        Next
    Next
    Return arrTempArray
#EndFunction

; set up WB array
arrR = ArrDimension(2,5)
arrR[0,0] = "Name"
arrR[0,1] = "Address"
arrR[0,2] = "City"
arrR[0,3] = "State"
arrR[0,4] = "Zip"
arrR[1,0] = "Deana"
arrR[1,1] = "5421 California Ave SW"
arrR[1,2] = "Seattle"
arrR[1,3] = "Wa"
arrR[1,4] = "98116"

infile = DirScript():"before.csv"
outfile = DirScript():"after.csv"

ArrayFilePutCSV( infile, arrR )
RunWait( infile, '' )

arrNew = ArrayTranspose(arrR)

ArrayFilePutCSV( outfile, arrNew )
RunWait( outfile, '' )

FileDelete(infile)
FileDelete(outfile)

Article ID:   W17669
Filename:   Transpose Array.txt
File Created: 2013:03:04:09:21:02
Last Updated: 2013:03:04:09:21:02