Burgs Posted June 29, 2012 Share Posted June 29, 2012 Hello, I am reading the following file into an array using the '_FileReadToArray' command: -1, -1, 0 -1, -1, 1 -1, -1, 2 -1, -1, 3 -1, -1, 4 -1, -1, 5 -1, -1, 6 -1, -1, 7 -1, -1, 8 -1, -1, 9 When completed the 'Array[0]' reports that 10 records have been read into the array...which means 1 record per line, does this mean a 2D array has been created? I would have thought '30' records should have been reported as read (10 lines each of 3 values)...how do I access the values within the array,..? Is, for example, the '15th' array value (the first '-1' on the 6th line/record) accessed using something like 'myvalue = $aArray[6][0]"...? Thanks in advance... Link to comment Share on other sites More sharing options...
water Posted June 29, 2012 Share Posted June 29, 2012 (edited) The function only creates a 1D array as you can see from "Array[0] reports ..." which has only 1 index and therefore is a one dimensional array. You have to split the values of each line yourself.Or you search the forum for a CSV read function like one. Edited June 29, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Mechaflash Posted June 29, 2012 Share Posted June 29, 2012 Did you check the output? #include <File.au3> #include <Array.au3> _FileReadToArray($file, $array) _ArrayDisplay($array) Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Burgs Posted June 29, 2012 Author Share Posted June 29, 2012 Thanks for the replies, yes I checked the output and I saw each of the 10 lines contains the 3 values...wow that is surprising I have to strip out the values into a 2D array...I thought the command would have done that already...thanks again. Link to comment Share on other sites More sharing options...
water Posted June 29, 2012 Share Posted June 29, 2012 Why should the command do that? The help file says "Reads the specified file into an array" not "Reads the file and splits each line into separate values storing it in a 2D array". How should the command know which structure the file has? If it is a CSV format (Comma Separated Values) then the link I posted is what you need. Mechaflash 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Mechaflash Posted June 29, 2012 Share Posted June 29, 2012 I don't see what's so surprising. The command does as what it's called... reads the file into an array. A string of data is just that. Just because it has commas doesn't mean that it knows it's supposed to treat it like a CSV. Jus' Sayin' Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Burgs Posted June 29, 2012 Author Share Posted June 29, 2012 Is there by any chance a command to read values into a 2D array? Link to comment Share on other sites More sharing options...
water Posted June 29, 2012 Share Posted June 29, 2012 As I posted above use the code written by ProgAndy. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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