VeeDub Posted March 22 Share Posted March 22 Hello, I'm trying to write code to add to a 2D array. I've tried to use the examples in the help as a template, but I'm doing something wrong which I can't see. What I'm trying to do is use an array to summarise the contents of a folder with a large number of files which I want to summarise by YYYY-MM So, if there are 100,000 files. I want to summarise those files by there timestamp. So, for each file: I will determine it's timestamp (YYYY-MM) Then I will lookup that timestamp in the array If the timestamp exists, I will add 1 to the counter If the timestamp does not exist in the array, I will add an entry with a count of 1 The code that I'm using to add an entry to the array doesn't work. #include <Array.au3> Global $FILE_Summary[500][1] $Timestamp_YYYY_MM = "2022-04" ; Search Array for YYYY-MM $iIndex = _ArraySearch($FILE_Summary,$Timestamp_YYYY_MM) If $iIndex = -1 Then ; Not found - add entry Local $sFill = $Timestamp_YYYY_MM & "|1" ConsoleWrite("sFill: " & $sFill & @CRLF) $Status = _ArrayAdd($FILE_Summary,$sFill) ConsoleWrite("Status: " & $Status & @CRLF) ConsoleWrite("@error: " & @error & @CRLF) EndIf _ArrayDisplay($FILE_Summary) sFill: 2022-04|1 Status: -1 @error: 3 error:3 = $vValue has too many columns to fit into $aArray Clearly there is a problem, but to me $sFill looks to be correct, so I need a fresh perspective. Thanks VW Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 22 Moderators Share Posted March 22 That's a lot... I'd just use a SQLite database. It'd be much faster if you're moving through that many files. Anyway, you're missing 2 parameters in your _ArrayAdd() VeeDub 1 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
VeeDub Posted March 23 Author Share Posted March 23 @SmOke_N The example I was following doesn't use any extra parameters ; Add item delimited string $aArray = $aArray_Base $sFill = "New Item 2 - 0|New Item 2 - 1" _ArrayAdd($aArray, $sFill) _ArrayDisplay($aArray, "2D - Item delimited") However, I have also tried to implement your suggestion #include <Array.au3> Global $FILE_Summary[500][1] $Timestamp_YYYY_MM = "2022-04" ; Search Array for YYYY-MM $iIndex = _ArraySearch($FILE_Summary,$Timestamp_YYYY_MM) If $iIndex = -1 Then ; Not found - add entry Local $sFill = $Timestamp_YYYY_MM & "|1" ConsoleWrite("sFill: " & $sFill & @CRLF) $Status = _ArrayAdd($FILE_Summary,$sFill,0) ConsoleWrite("Status: " & $Status & @CRLF) ConsoleWrite("@error: " & @error & @CRLF) EndIf _ArrayDisplay($FILE_Summary) sFill: 2022-04|1 Status: -1 @error: 3 I'm now specifying column: 0 I don't believe that I need to specify Delim_Row. Maybe I really do - and that's the issue. However my thinking is that I'm adding a row with 2 columns: 2022-04 | 1 Link to comment Share on other sites More sharing options...
Solution Gianni Posted March 23 Solution Share Posted March 23 try with Global $FILE_Summary[500][2] VeeDub 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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