GordonFreeman 11 Posted January 14, 2016 (edited) Hi guys. I am trying to convert this array to this other (or create a new) I dont know this number (vars)Stephany | 9851Franklin | 3001Lisa | 9851Dylan | 9851Ashley | 3001Jimmy | 2115Hilary | 2115Johnson | 2115Eno | 1500Gal | 2115Into==>Stepanhy | Lisa | Dylan |Franklin | Ashley |Jimmy | Hilary | Johnson | GalEno | | | #include <Array.au3> Global $aNamesID[10][2] = _ [["Stephany",9851] _ ,["Franklin",3001] _ ,["Lisa" ,9851] _ ,["Dylan" ,9851] _ ,["Ashley" ,3001] _ ,["Jimmy" ,2115] _ ,["Hilary" ,2115] _ ,["Johnson" ,2115] _ ,["Eno" ,1500] _ ,["Gal" ,2115]] _ArrayDisplay($aNamesID) Edited January 14, 2016 by GordonFreeman Frabjous Installation Share this post Link to post Share on other sites
JLogan3o13 1,623 Posted January 14, 2016 (edited) Your question is a bit vague, but I am assuming you want to take the 2D array and create a 1D with just the names? Something like this?#include <Array.au3> Local $aFinal[0] Global $aNamesID[10][2] = _ [["Stephany",9851] _ ,["Franklin",3001] _ ,["Lisa" ,9851] _ ,["Dylan" ,9851] _ ,["Ashley" ,3001] _ ,["Jimmy" ,2115] _ ,["Hilary" ,2115] _ ,["Johnson" ,2115] _ ,["Eno" ,1500] _ ,["Gal" ,2115]] ;_ArrayDisplay($aNamesID) For $i = 0 To 9 _ArrayAdd($aFinal, $aNamesID[$i][0]) Next _ArrayDisplay($aFinal) Or are you saying you want to break the names up into different columns in another 2D array? Edited January 14, 2016 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Share this post Link to post Share on other sites
GordonFreeman 11 Posted January 14, 2016 Your question is a bit vague, but I am assuming you want to take the 2D array and create a 1D with just the names? Something like this?#include <Array.au3> Local $aFinal[0] Global $aNamesID[10][2] = _ [["Stephany",9851] _ ,["Franklin",3001] _ ,["Lisa" ,9851] _ ,["Dylan" ,9851] _ ,["Ashley" ,3001] _ ,["Jimmy" ,2115] _ ,["Hilary" ,2115] _ ,["Johnson" ,2115] _ ,["Eno" ,1500] _ ,["Gal" ,2115]] ;_ArrayDisplay($aNamesID) For $i = 0 To 9 _ArrayAdd($aFinal, $aNamesID[$i][0]) Next _ArrayDisplay($aFinal) Or are you saying you want to break the names up into different columns in another 2D array?Yes, sorry. The number of columns will depend of most repeated id. In other words i want group every name with your ID. By example, Franklin and Ashley have the same ID. Franklin will be [X][0] and ashley will be [X][1]. Each "line" will reserved for each ID. Thanks in advance! Frabjous Installation Share this post Link to post Share on other sites
Danyfirex 659 Posted January 14, 2016 (edited) Just for fun...expandcollapse popup#include <Array.au3> Global $aNamesID[10][2] = _ [["Stephany", 9851] _ , ["Franklin", 3001] _ , ["Lisa", 9851] _ , ["Dylan", 9851] _ , ["Ashley", 3001] _ , ["Jimmy", 2115] _ , ["Hilary", 2115] _ , ["Johnson", 2115] _ , ["Eno", 1500] _ , ["Gal", 2115]] _ArrayDisplay($aNamesID) Local $aNewArray[0][0] Local $aFound = 0 Local $iFlagIndex = 0 local $iMaxIndex = 0 Local $c = 0 For $i = 0 To UBound($aNamesID) - 1 $iMaxIndex = _ArrayMax($aNamesID, 1, Default, Default, 1) $aFound = _ArrayFindAll($aNamesID, $iMaxIndex, 0, 0, 0, 0, 1) ;_ArrayDisplay($aFound) If IsArray($aFound) Then ReDim $aNewArray[UBound($aNewArray, 1) + 1][UBound($aNewArray, 2)] If UBound($aNewArray, 2) < UBound($aFound) Then ReDim $aNewArray[UBound($aNewArray, 1)][UBound($aFound)] For $x = 0 To UBound($aFound) - 1 $aNewArray[UBound($aNewArray, 1) - 1][$x] = $aNamesID[Int($aFound[$x])][0] $aNamesID[Int($aFound[$x])][1] = Null Next $iFlagIndex += UBound($aFound) EndIf If $iFlagIndex = UBound($aNamesID, 1) Then ExitLoop Next _ArrayDisplay($aNewArray)Saludos Edited January 14, 2016 by Danyfirex 1 GordonFreeman reacted to this Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Share this post Link to post Share on other sites
JLogan3o13 1,623 Posted January 14, 2016 Yes, sorry. The number of columns will depend of most repeated id. In other words i want group every name with your ID. By example, Franklin and Ashley have the same ID. Franklin will be [X][0] and ashley will be [X][1]. Each "line" will reserved for each ID. Thanks in advance!This would have been helpful in your OP "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Share this post Link to post Share on other sites
GordonFreeman 11 Posted January 14, 2016 Just for fun...expandcollapse popup#include <Array.au3> Global $aNamesID[10][2] = _ [["Stephany", 9851] _ , ["Franklin", 3001] _ , ["Lisa", 9851] _ , ["Dylan", 9851] _ , ["Ashley", 3001] _ , ["Jimmy", 2115] _ , ["Hilary", 2115] _ , ["Johnson", 2115] _ , ["Eno", 1500] _ , ["Gal", 2115]] _ArrayDisplay($aNamesID) Local $aNewArray[0][0] Local $aFound = 0 Local $iFlagIndex = 0 local $iMaxIndex = 0 Local $c = 0 For $i = 0 To UBound($aNamesID) - 1 $iMaxIndex = _ArrayMax($aNamesID, 1, Default, Default, 1) $aFound = _ArrayFindAll($aNamesID, $iMaxIndex, 0, 0, 0, 0, 1) ;_ArrayDisplay($aFound) If IsArray($aFound) Then ReDim $aNewArray[UBound($aNewArray, 1) + 1][UBound($aNewArray, 2)] If UBound($aNewArray, 2) < UBound($aFound) Then ReDim $aNewArray[UBound($aNewArray, 1)][UBound($aFound)] For $x = 0 To UBound($aFound) - 1 $aNewArray[UBound($aNewArray, 1) - 1][$x] = $aNamesID[Int($aFound[$x])][0] $aNamesID[Int($aFound[$x])][1] = Null Next $iFlagIndex += UBound($aFound) EndIf If $iFlagIndex = UBound($aNamesID, 1) Then ExitLoop Next _ArrayDisplay($aNewArray)SaludosThanks! Frabjous Installation Share this post Link to post Share on other sites
jguinch 432 Posted January 14, 2016 Another way :expandcollapse popup#include <Array.au3> Local $aFinal[0] Global $aNamesID[10][2] = _ [["Stephany",9851] _ ,["Franklin",3001] _ ,["Lisa" ,9851] _ ,["Dylan" ,9851] _ ,["Ashley" ,3001] _ ,["Jimmy" ,2115] _ ,["Hilary" ,2115] _ ,["Johnson" ,2115] _ ,["Eno" ,1500] _ ,["Gal" ,2115]] ReDim $aNamesID[UBound($aNamesID)][UBound($aNamesID)] _ArraySort($aNamesID, 0, 0, 0, 1) Local $iIndex = 0, $iLastID = -1, $iCol = 1, $iMaxCol = 0 For $i = 0 To UBound($aNamesID) - 1 If $aNamesID[$i][1] = $iLastID Then $iCol += 1 $aNamesID[$iIndex][$iCol] = $aNamesID[$i][0] If $iCol > $iMaxCol Then $iMaxCol = $iCol Else If $i > 0 Then $iIndex += 1 $iLastID = $aNamesID[$i][1] $aNamesID[$iIndex][1] = $aNamesID[$i][0] $aNamesID[$iIndex][0] = $iLastID $iCol = 1 EndIf Next Redim $aNamesID[$iIndex + 1][$iMaxCol + 1] _ArrayDisplay($aNamesID) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Share this post Link to post Share on other sites
jdelaney 313 Posted January 15, 2016 (edited) Although not exactly what you asked for, I would go an array of arrays route...so global redims aren't required which will populate lots of blank values:#include <Array.au3> Global $aNamesID[10][2] = _ [["Stephany",9851] _ ,["Franklin",3001] _ ,["Lisa" ,9851] _ ,["Dylan" ,9851] _ ,["Ashley" ,3001] _ ,["Jimmy" ,2115] _ ,["Hilary" ,2115] _ ,["Johnson" ,2115] _ ,["Eno" ,1500] _ ,["Gal" ,2115]] Local $aTemp[1] = [$aNamesID[0][0]] Global $aNew[1][2] = [[$aNamesID[0][1],$aTemp]] For $i = 1 To UBound($aNamesID)-1 $iTemp = _ArraySearch($aNew,$aNamesID[$i][1],Default,Default,Default,Default,Default,0) If $iTemp >= 0 Then $aTemp = $aNew[$iTemp][1] _ArrayAdd($aTemp,$aNamesID[$i][0]) $aNew[$iTemp][1] = $aTemp Else Local $aTemp[1]=[$aNamesID[$i][0]] ReDim $aNew[UBound($aNew)+1][2] $aNew[UBound($aNew)-1][0] = $aNamesID[$i][1] $aNew[UBound($aNew)-1][1] = $aTemp EndIf Next _ArrayDisplay($aNew) For $i = 0 To UBound($aNew) _ArrayDisplay($aNew[$i][1]) Next Edited January 15, 2016 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Share this post Link to post Share on other sites