xcaliber13 Posted November 9, 2018 Posted November 9, 2018 I have another array question. How would I combine columns in an array. Lets say I have columns 171, 172, 173 and I want all the data combined into column 171. Thank you
Nine Posted November 9, 2018 Posted November 9, 2018 Not clear, give an example of content of the 3 cells and the result. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Multi-Threading Made Easy
iamtheky Posted November 9, 2018 Posted November 9, 2018 (edited) 2D to 1D **though if in a larger array you will probably have to use ArrayExtract to get the pieces you want, and ArrayColDelete before you ArrayColInsert the new column back in. #include<array.au3> local $arr[3][3] = [[1,4,7],[2,5,8],[3,6,9]] _ArrayDisplay($arr) _ArrayDisplay(stringsplit(_ArrayToString($arr , "|" , -1 , -1 , "|") , "|" , 2)) Edited November 9, 2018 by iamtheky my awful explainer ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Malkey Posted November 9, 2018 Posted November 9, 2018 Try this. #include <Array.au3> ; Create sample array Local $aArray_Base[10][180] For $i = 0 To UBound($aArray_Base) - 1 For $j = 0 To UBound($aArray_Base, 2) - 1 $aArray_Base[$i][$j] = $i & "-" & $j Next Next _ArrayDisplay($aArray_Base, "before") Local $aColsToCombine[] = [171, 172, 173] ; Indexes of columns to combine. ; Combine columns For $j = 1 To UBound($aColsToCombine) - 1 For $i = 0 To UBound($aArray_Base) - 1 $aArray_Base[$i][$aColsToCombine[0]] &= $aArray_Base[$i][$aColsToCombine[$j]] & " " ; Space used to separate data from each column. Next Next ; Delete unwanted columns For $j = UBound($aColsToCombine) - 1 To 1 Step -1 _ArrayColDelete($aArray_Base, $aColsToCombine[$j]) Next _ArrayDisplay($aArray_Base, "after")
xcaliber13 Posted November 12, 2018 Author Posted November 12, 2018 Malkey, That is exactly what I needed. Just had to adjust one line to make it fit my needs perfectly. Changed: $aArray_Base[$i][$aColsToCombine[0]] &= $aArray_Base[$i][$aColsToCombine[$j]] & " " ; Space used to separate data from each column. To $aArray_Base[$i][$aColsToCombine[0]] &=" "&$aArray_Base[$i][$aColsToCombine[$j]] & " " ; Space used to separate data from each column. That gave me the correct spacing I needed. Again Thank you GreeNerO 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now