Jump to content

_ArrayAdd + MultiDimensional Array..??


Recommended Posts

That will need a ReDim somewhere, likely to add only one more entry at a time. If you're going to add up to the million rows, then that will sum up to as much ReDim. You should probably allocate new entries by chunks of 64, 256 or 1024 (I just love 2).

BTW, my answer to the other post still holds and further begs a question: will you search in this array? How?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

This seems less straight forward than I thought it would be. I haven't looked at the UDF, but I have thought about a possible solution. It's a bit long winded though. Create the new entries in a second array. Then when you are satisfied with the new entries, create a third array large enough to hold all the entries. Voila!

For Example:

#include <Array.au3>

Local $a1[2][2], $a2[2][2]

$a1[0][0] = 1
$a1[0][1] = "a"
$a1[1][0] = 2
$a1[1][1] = "b"

$a2[0][0] = 3
$a2[0][1] = "c"
$a2[1][0] = 4
$a2[1][1] = "d"

Local $a3[Ubound($a1) + UBound($a2)][2]

For $i = 0 To UBound($a1) -1
    $a3[$i][0] = $a1[$i][0]
    $a3[$i][1] = $a1[$i][1]
Next

$j = 0
For $i = Ubound($a1) To Ubound($a3) -1
    $a3[$i][0] = $a2[$j][0]
    $a3[$i][1] = $a2[$j][1]
    $j += 1
Next
;_ArrayDisplay($a3)

$a1 = $a3
_ArrayDisplay($a1)

If you use this method, make sure you make the second array large enough to hold all the new entries. Count the number of entries as you add them, to determine the size of the third array.

Edited by czardas
Link to comment
Share on other sites

Yes of course that's possible!

#include <Array.au3>

Local $a[5][3]
$a[0][0] = "abc"
$a[4][2] = "def"
_ArrayDisplay($a)

ReDim $a[6][3]
$a[5][1] = "ghi"
_ArrayDisplay($a)

But it doesn't make much sense to me: what happens at a power outage, can you recreate the data easily?

@czardas: PLEASE!

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Yes of course that's possible!

#include <Array.au3>

Local $a[5][3]
$a[0][0] = "abc"
$a[4][2] = "def"
_ArrayDisplay($a)

ReDim $a[6][3]
$a[5][1] = "ghi"
_ArrayDisplay($a)

But it doesn't make much sense to me: what happens at a power outage, can you recreate the data easily?

@czardas: PLEASE!

Sorry JCHD, I'm not sure what power outages have to do with it. If there's a more reliable way to do this then okay. Perhaps I missed something? Chances are you are going to lose data at a power outage anyway? I have not used Redim before, so I'll check it out. I think your method is better. Thanks for the tip. Edited by czardas
Link to comment
Share on other sites

Accumulating millions of entries is likely to take some time, in particular when the OP talks about dumping the array to a speadsheet "every so often". That evokes some persistence to me and I naturally ask about data re-creation in case of power outage or system crash à la BSOD. Memory "storage" isn't really storage...(*)

I continue to believe that an SQLite DB would do it more nicely, but that also depend on the rate of inserts and/or updates and the expected size of the cells.

About your solution: it's a terrible idea. Where did you get it?

* Not everybody can get it: I mean "now".(**)

** For those who still don't get it, memory storage has been persistent at some time in IT history and ... well ... I've been there!

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Accumulating millions of entries is likely to take some time, in particular when the OP talks about dumping the array to a speadsheet "every so often". That evokes some persistence to me and I naturally ask about data re-creation in case of power outage or system crash à la BSOD. Memory "storage" isn't really storage...

I continue to believe that an SQLite DB would do it more nicely, but that also depend on the rate of inserts and/or updates and the expected size of the cells.

About your solution: it's a terrible idea. Where did you get it?

My solution is a terrible idea! Come on. Cap the number of new entries and update as you go. The solution I presented has some advantages. The Redim method may have some disadvantages. Considering I didn't know about Redim my solution is damn good. Where did I get it? Product of a fertile imagination. :(

Besides: the OP never mentioned anything about millions of entries.

Edited by czardas
Link to comment
Share on other sites

My solution is a terrible idea! Come on. Cap the number of new entries and update as you go. The solution I presented has some advantages.

Allocate a 1Kb fixed-size file on a 2Tb harddisk. When the file is populated, allocated another 1Kb fixed-size file on another 2Tb harddisk. When the second file is fully populated, allocate a fixed-size 2Kb file onto a third harddisk where you can merge your two 1K files.

I admit I'm a bit making it up, but I'm sorry but it was not a good idea at all.

Besides: the OP never mentioned anything about millions of entries.

Sure!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Ok I got a couple of hours shut eye, and now have I looked at the other thread. To add to JCHD's earlier comments, an excel spread sheet holds a maximum of 2^16 rows. That's no where near a million. SQLite sounds good, I think I'll give it a try.

One final thought on this: I am not at all convinced that the method I came up with is so bad. You either keep updating the main array, one entry at a time, or you do it in chunks. The methods are simply different, not better or worse. One of the advantages to updating in chunks is that you do not need to hold all the information in RAM while you add new entries. You only need to do that when you update the main data dump, be it a spread sheet or whatever. And with Redim you only need to use two arrays (or if you're clever only one array) instead of three. I didn't know that yesterday.

Edited by czardas
Link to comment
Share on other sites

ReDim reallocates the array. It doesn't have to copy the data anywhere. Only one copy ever exists. No copy needed.

Sorry to point that out: your approach is bad in that it needs twice as much array writes and twice as much memory compared to ReDim.

And, as I already noted, ReDim should be made in chunks, not one entry at a time.

SQLite offers large storage (up to 500Gb per database), instant sorting using indexing, proven reliability, ACID transactions, live backups, superfast queries, ...

Excel 2007 allows for 2^14 columns and 2^20 rows.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

No problem, you're welcome!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...