Sign in to follow this  
Followers 0
marko001

Converting Array 1D-2D

3 posts in this topic

Hi,

I have a file I can open and get Arrival Times of Buses:

$sArray = _StringBetween($hfile,"Arrival_Time:",">",-1)

that creates me an 1D Array

Every line is more or less:

[0] [Monday,  23:50]
[1] [Tuesday, 11:45]
..
..

I want, from this $sArray, to create a new 2D Array:

$sDetailed_Array

where i could have:

[0][Monday][23:50]
[1][Tuesday][11:45]
[2][...]    [...]

I tried StringSplit but it doesn't work so well.

Any suggestions?

Thanks,

M.

Share this post


Link to post
Share on other sites



#include <array.au3>

;..
Dim $aArray[2]
$aArray[0] = 'Monday,  23:50'
$aArray[1] = 'Tuesday, 11:45'
;...

Dim $aArray2D[UBound($aArray)][2]

For $i = 0 To UBound($aArray)-1
    $aSplitted = StringSplit(StringStripWS($aArray[$i], 8), ',')

    If $aSplitted[0] <> 2 Then
        MsgBox(16, 'Error', 'Wrong text!')
        Exit
    EndIf

    $aArray2D[$i][0] = $aSplitted[1]
    $aArray2D[$i][1] = $aSplitted[2]
Next

_ArrayDisplay($aArray2D)

Share this post


Link to post
Share on other sites

Solved! Thanks a lot!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0