ur Posted February 8, 2018 Posted February 8, 2018 (edited) I am reading a CSV file which is tab seperated as below. Local $aArray = FileReadToArray($file) And now, I am splitting this main array record wise so that Array contains internally another arrow to represent each row. For $i = 0 to (UBound($aArray) - 1) ;MsgBox(0,"",$aArray[$i]) $aArray[$i] = StringSplit(StringStripCR($aArray[$i]), Chr(9),2);Chr(9) for tab ;_ArrayDisplay($aArray[$i]) Next Afther that, _ArrayDIsplay is able to see the individual internal arrays. _ArrayDisplay($aArray[1]) But If I try to access the individual element of it as below.It is not showing any result. MsgBox(0,"",$aArray[1][1]) Any suggestion, below is the sample csv file. New Text Document.csv Edited February 8, 2018 by ur
Andreik Posted February 8, 2018 Posted February 8, 2018 It's not a multidimensional array. StringSplit function returns a single column array.
SlackerAl Posted February 8, 2018 Posted February 8, 2018 You are ending up with an array of arrays... easier solution, use _FileReadToArray #include <Array.au3> #include <File.au3> Local $aArray _FileReadToArray("E:\AutoIT\Programs\Test\New Text Document.csv", $aArray, 1, " ") _ArrayDisplay($aArray) MsgBox(0,"",$aArray[1][2]) You can specify multiple delimiter characters in the final argument. Earthshine 1 Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.
jdelaney Posted February 8, 2018 Posted February 8, 2018 (edited) Local $subArray[4] = [1,2,3,4] Local $parentArray[1] = [$subArray] _ArrayDisplay($parentArray[0]) For $i = 0 To UBound($parentArray[0])-1 ConsoleWrite(($parentArray[0])[$i] & @CRLF) Next Direct answer to your question ^ You can also create a temporary variable, and set that to the internal array, and then loop through that temp array. Edited February 8, 2018 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.
ur Posted February 9, 2018 Author Posted February 9, 2018 Many Thanks for your replies. It is working if I surround it with braces. ;MsgBox(0,"",$aArray[1][1]) MsgBox(0,"",($aArray[1])[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