youngjohn Posted November 2, 2018 Share Posted November 2, 2018 I have a very simple script to read a text file into an array. But when I try to use any of the element in the array I got the error. Here is the script: #include <Date.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Array.au3> $Title = "Testing ..." $RawFilePath = "C:\Premier\Variant\DATA\2018\0511\002506001.raw" ; read raw file Global $aRawData _FileReadToArray($RawFilePath, $aRawData, $FRTA_NOCOUNT, "|") _ArrayColDelete($aRawData, 1) MsgBox(0, $Title, "First point: " & $aRawData[0]) The error is at $aRawData[0] on the last line. File 002506001.raw is attached. I was able to use _ArrayDisplay() to show it in list view. 002506001.raw Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 2, 2018 Share Posted November 2, 2018 (edited) Hi @youngjohn, and welcome to the AutoIt forums You forgot an important parameter, especially in your case: $bConvert [optional] If True then if only one column remains the array is converted to 1D So, adding it to your script: #include <Date.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Array.au3> $Title = "Testing ..." $RawFilePath = "C:\Premier\Variant\DATA\2018\0511\002506001.raw" ; read raw file Global $aRawData _FileReadToArray($RawFilePath, $aRawData, $FRTA_NOCOUNT, "|") _ArrayDisplay($aRawData, "Before deleting Column 1 (Second Column):") _ArrayColDelete($aRawData, 1, True) MsgBox(0, $Title, "First point: " & $aRawData[0]) You can have a 1-Dimension array Edited November 2, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
youngjohn Posted November 2, 2018 Author Share Posted November 2, 2018 Thank you, FrancescoDiMuro! Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 2, 2018 Share Posted November 2, 2018 @youngjohn Happy to have helped Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Subz Posted November 2, 2018 Share Posted November 2, 2018 (edited) Or you could have used $aRawData[$i][0] for the first column and $aRawData[$i][2] for second column etc... For $i = 0 To Ubound($aRawData) - 1 ConsoleWrite("First Column = " & $aRawData[$i][0] & ", Second Column = " & $aRawData[$i][1] & @CRLF) Next Edited November 2, 2018 by Subz Link to comment Share on other sites More sharing options...
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