+ Reply to Thread
Results 1 to 6 of 6

Array slicing optimisation

  1. #1
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Array slicing optimisation

    Hi All,

    I am optimising some code and need to be able to slice large arrays and am hoping that there is a more efficient way.

    The arrays are 40k lines plus.

    I currently loop through three workbooks, each with 40k lines and, I put each range directly into a variant array, then into an array.

    I then loop through the array to access each sub array and convert each sub array to 1d so I can use the filter function. I have tried using INDEX and tried transposing the data from each workbook, both error, which I'm assuming is due to the size of the data.

    Currently I'm using the below (which is an excerpt):

    Please Login or Register  to view this content.
    To give a bit more background, the files are TabDelimited and I need to find given words (60+) that may exist on any row, and in any of a number of fields on each row.

    I've also tried Querying the workbooks with ADO and filtering the recordsets, but this was unbelievably slow.

    Any ideas as to whether this can be sped up at all? / Better way of attacking the problem?

    Cheers

    Kyle
    Last edited by Kyle123; 02-01-2012 at 10:44 AM.

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Array slicing optimisation

    Did you try ADO (either UNION query or three separate queries), then GetRows to put the data into an array? You could also restrict the data using a WHERE clause with Like (though that might not be very fast).
    Good luck.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Array slicing optimisation

    Yes, I tried that, but GetRows() still returns a 2d array which needs to be sliced. Also I can restrict the data, but I'd need to run more queries :S

    Looks like looping through might be the only option then

    Thanks for looking

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Array slicing optimisation

    Much simpler ( and faster !):

    Please Login or Register  to view this content.
    sn is a 0-dimensional array containing all 'rows' in the csv-file that contain the searched for textstring.

    You can even add the content of all csv files into 1 string before splitting and filtering.



  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Array slicing optimisation

    as an option
    Please Login or Register  to view this content.
    *it works with Russian local settings

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Array slicing optimisation

    Great suggestions, Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1