Jump to content

ArrayFindAll values


Recommended Posts

  • Moderators

Like most things in AutoIt, there are multiple ways to do it, depending on 1D, 2D, etc. How about an example of the array you're working with and the values you're trying to capture, rather than asking us to guess? ;)

 

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Why would you need to retrieve the values from the array? You could just replace all of the indices returned with the second parameter of the arrayfindall function?

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I would use grep to search the log file direct

grepWin is free

https://stackoverflow.com/questions/87350/what-are-good-grep-tools-for-windows

 

I use BareGrep, and there IS a freeware version.. I loved it so much, I bought BareGrep and BareTail Pro

https://www.baremetalsoft.com/baregrep/

 

baregrep is so fast you can use it as a file search... LOL 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

31 minutes ago, LoneWolf_2106 said:

Because from a bigger Array, containing a log file, i needed to filter some values and then filter once more this filtered data using _ArrayUnique

can you copy a small snippet of the log file?  I would like a crack at one-shotting the expected return out of the logfile, but we cant play along without some source data.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

If you have two unique 1D arrays in alphabetical order, then you can extract all matching values quite quickly using this algorithm:

I'm not entirely sure if this fits your situation. The code needs to be adapted to return an array. I can modify it, but I also need you post an example of the log file.

Edited by czardas
Link to comment
Share on other sites

... an example of a simple function that uses the same parameters of _ArrayFindAll(), but it returns whole lines instead of just indexes. I've called it _ArrayFindAll_2()  in the listing. Anyway, If you search values of a single row (see the last parameter $bRow), OR if you pass an 1D array then the function returns only indexes , as it would be a nonsense to return  the searched string repeated as many times as the number of time it's found.

#include <array.au3>
Example()

Func Example()
    Local $aMyArray = [["Col.0 First name", "Col.1 Last name", "Col.2 Position", "Col.3 Office", "Col.4 Salary"], _
            ["Airi", "Satou", "Accountant", "Tokyo", "$162,700"], _
            ["Angelica", "Ramos", "Chief Executive Officer (CEO)", "London", "$1,200,000"], _
            ["Ashton", "Cox", "Junior Technical Author", "San Francisco", "$86,000"], _
            ["Bradley", "Greer", "Software Engineer", "London", "$132,000"], _
            ["Brenden", "Wagner", "Software Engineer", "San Francisco", "$206,850"], _
            ["Brielle", "Williamson", "Integration Specialist", "New York", "$372,000"], _
            ["Bruno", "Nash", "Software Engineer", "London", "$163,500"], _
            ["Caesar", "Vance", "Pre-Sales Support", "New York", "$106,450"], _
            ["Cara", "Stevens", "Sales Assistant", "New York", "$145,600"], _
            ["Cedric", "Kelly", "Senior Javascript Developer", "Edinburgh", "$433,060"]]

    ; search the array for "New York" in column 3
    _ArrayDisplay(_ArrayFindAll_2($aMyArray, "New York", Default, Default, Default, Default, 3))
EndFunc   ;==>Example

; This function Returns whole rows instead of just indexes
; --------------------------------------------------------
Func _ArrayFindAll_2(ByRef $aArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iSubItem = 0, $bRow = False)

    Local $aIndexes = _ArrayFindAll($aArray, $vValue, $iStart, $iEnd, $iCase, $iCompare, $iSubItem, $bRow)
    If @error Then Return SetError(@error, 0, -1)

    ; if searching only in a row, OR if it's an 1D array then return indexes
    ; is nonsense to returns values in this cases, (it would be returned the searched string repeated)
    If $bRow Or UBound($aArray, 0) = 1 Then Return $aIndexes

    Local $iRows = UBound($aIndexes, 1), $iColumns = UBound($aArray, 2)
    Local $aReturn[$iRows][$iColumns]
    For $iRow = 0 To $iRows - 1
        For $iColumn = 0 To $iColumns - 1
            $aReturn[$iRow][$iColumn] = $aArray[$aIndexes[$iRow]][$iColumn]
        Next
    Next

    Return $aReturn
EndFunc   ;==>_ArrayFindAll_2

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

@everybody: Thank you so much for the effort, i have solved just using a second array copying the values, it is okay :-) we are in 2017, some Kilobyte more it is not a big issue :-)

Just for Information my logfile contains entries like:

INFO [13.12.2017 13:04:13] [http-bio-8080-exc-5] File: data\dud\ID001704.xdu Timestamp (toString): 2015-06-25T09:27:33.603773Z Timestamp (toMillis): 1435224453603Timestamp (Gregorian): 2015-06-25T09:27:33.603Z


INFO [13.12.2017 13:46:57] [http-bio-8080-exc-9] [ATSL16, A222] Update request- client version: 5.2.21_28.11.2017 server version: 5.2.21_28.11.2017

INFO [13.12.2017 13:48:28] [pool-3-thread-1] Log message has been sent to application: MDU Online Update, url: http://XYZ Response code: 201

etc.

But as i said, it is okay, i have solved in another way.  

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...