LoneWolf_2106 Posted December 13, 2017 Share Posted December 13, 2017 Hi, is there any function like _ArrayFindAll but which returns an array with found values instead of the indices? Thanks in advance for the support Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 13, 2017 Moderators Share Posted December 13, 2017 (edited) 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 December 13, 2017 by JLogan3o13 Earthshine 1 "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 More sharing options...
LoneWolf_2106 Posted December 13, 2017 Author Share Posted December 13, 2017 I have solved copying the values in a secondary Array using the indices retrieved by _ArrayFindAll. My question was just to know if there was a function which does that. Link to comment Share on other sites More sharing options...
iamtheky Posted December 13, 2017 Share Posted December 13, 2017 (edited) 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 December 13, 2017 by iamtheky Earthshine 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
LoneWolf_2106 Posted December 13, 2017 Author Share Posted December 13, 2017 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 Link to comment Share on other sites More sharing options...
Earthshine Posted December 13, 2017 Share Posted December 13, 2017 (edited) 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 December 13, 2017 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
iamtheky Posted December 13, 2017 Share Posted December 13, 2017 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 More sharing options...
czardas Posted December 13, 2017 Share Posted December 13, 2017 (edited) 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 December 13, 2017 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Gianni Posted December 13, 2017 Share Posted December 13, 2017 ... 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. expandcollapse popup#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 dmob 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...
LoneWolf_2106 Posted December 14, 2017 Author Share Posted December 14, 2017 @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 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