Jump to content

How to combine two 2d arryas, to a 3d array


Recommended Posts

Hi!

I got two arrays containting information wich are linked to eacht other(position 1 in array 1 contains information about position 1 in array 2, and I'm getting really frustrated of constantly accessing 2 different arrays.

How do I combine the two (2d) arrays, into 1 3d array? And how do I acces this array with functions like _arrayToString?

Much Obliged, and thanks in advance!

Thomas

Link to comment
Share on other sites

  • Moderators

ThomasQ,

I am sure something can be done to combine your data, but could you please give us an idea of what exactly the arrays look like and how they inter-relate. If you could provide an idea of what you want as a final result that would also be extremely useful. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks!

The script I'm making has to do with Sport results. The raw data is being read from our website with _IEBodyReadText, and then sorted with String Explode. Then I use Array Find All to find the entries containing Outcomes, and I use Array Find All to find all the entries containing Dates. So I end up with 2 arrays containing the positions of the info I want from the main array. These positions are linked -> array 1, position 1, is the outcome of the match played on the date in array 2 position 1.

To make my scripting live easier, I would like to make a 3d array containg the outcome in the first column, and the date in the 2nd column. So I need a way to make the 3d array, and then fill it accordingly..

Thanks in advance

PS the main array is full of other data i can't use, and using the Array Find All function is the fastest way to sort it out. The two different 2d arrays are therefore needed.

Edited by ThomasQ
Link to comment
Share on other sites

  • Moderators

ThomasQ,

I would like to make a 3d array containg the outcome in the first column, and the date in the 2nd column

I do not think you want a 3D array, I think you want a 2D array with a number of columns. :(

If I understand you correctly, you have 2 arrays like this:

Index      Array 1           Array 2
0          Date of match 1   Outcome of Match 1
1          Date of match 2   Outcome of Match 2
2          Date of match 3   Outcome of Match 3
3          Date of match 4   Outcome of Match 4

To combine the arrays, you need to do something like this:

#include <Array.au3>

Global $aDates[4] = ["Date 1", "Date 2", "Date 3", "Date 4"]
$iSize = UBound($aDates)

Global $aOutcomes[4] = ["Outcome 1", "Outcome 2", "Outcome 3", "Outcome 4"]

Global $aCombined[$iSize][2]

If $iSize <> UBound($aOutcomes) Then MsgBox(0, "Error", "Arrays  are mismatched")

For $i = 0 To $iSize - 1

    $aCombined[$i][0] = $aDates[$i]
    $aCombined[$i][1] = $aOutcomes[$i]

Next

_ArrayDisplay($aCombined)

I hope this helps. If I have misuderstood or if this is not quite right, please ask again. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 1 year later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...