Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/21/2017 in all areas

  1. .... If you like to play with SQL give also a try to the following script ... #include <File.au3> #include 'ArraySql.au3' ; <-- Get this from the following link: ; https://www.autoitscript.com/forum/topic/166536-manage-arrays-by-means-of-sql/?do=findComment&comment=1234441 Local $ar _FileReadToArray("results.txt", $ar, $FRTA_ENTIRESPLIT, ": ") _ArrayToDbTable($ar, "DBarray") ; Transform the array into a Memory SQLite DB called "DBarray" _SQLite_Exec($g__hMemDb, "UPDATE DBarray SET Column1 = replace(Column1, ',', '.' );") ; change "," with "." ; Perform the SQL Query $aResult = _ArrayFromSQL("SELECT column0, AVG(Column1) FROM DBarray GROUP BY Column0 ORDER BY column0;") If Not @error Then _ArrayDisplay($aResult, "result of query") Else MsgBox(0, "error", $g__sSQLiteError) EndIf
    1 point
  2. .. and you don't get any error? Are you running from SciTE with f5? if not, what happens when you do? Jos
    1 point
  3. iamtheky

    Compare Two 2D Arrays

    3rd time is the charm? Think I was just making it too retardedly hard trying to be all mathy about it #include <Array.au3> Local $aArray1[6][3] = [[1, "Dog", "1111"], [2, "Ant", "2222"], [3, "Frog", "3333"], [4, "Duck", "4444"], [5, "E", "5555"], [ 6, "Tree", "6666"]] Local $aArray2[3][2] = [[2, "Ant"], [14, "Duck"],[ 1,"Tree"]] For $i = UBound($aArray1) - 1 To 0 step -1 For $j = UBound($aArray2) - 1 to 0 step - 1 If $aArray1[$i][1] = $aArray2[$j][1] OR $aArray1[$i][1] = "E" Then _ArrayDelete($aArray1 , $i) exitloop EndIf Next Next _ArrayDisplay($aArray1) edit: reduced
    1 point
  4. A try... #include <File.au3> Local $ar _FileReadToArray("results.txt", $ar, $FRTA_ENTIRESPLIT, ": ") _ArrayDisplay($ar) $u = _ArrayUnique($ar) _ArrayColInsert($u, 1) ;_ArrayDisplay($u) For $i = 1 to $u[0][0] Local $tmp = "", $n = 0 For $j = 0 to UBound($ar)-1 $ar[$j][1] = StringReplace($ar[$j][1], ",", ".") If $u[$i][0] = $ar[$j][0] Then $n += 1 $tmp += $ar[$j][1] EndIf Next $u[$i][1] = StringReplace($tmp/$n, ".", ",") Next _ArrayDisplay($u) Local $txt For $i = 1 to UBound($u)-1 $txt &= StringReplace($u[$i][0], " ", "_") & ";" & $u[$i][1] & @crlf Next FileWrite("my_csv.csv", $txt) Edit I didn't see the last requirement - the csv thing BTW using a comma as delimiter is not a good idea, since the values are european decimals using a comma instead of a dot
    1 point
  5. ok my guess wasnt too far off: This snippet grabs all the matching things in [0] and sums their values stored in [1], can we start from this code edit: which now returns the average of the values in [1] for items returned matching [0] #include <Array.au3> Local $aArray[4][2] = [["Thing1", "10"], ["Thing2", "10"], ["Thing1", "20"], ["Thing2", "40"]] Local $outArray[0][2] For $k = ubound($aArray) - 1 to 0 step -1 $aItems = _ArrayFindAll($aArray , $aArray[$k][0]) $x = 0 for $i = 0 to UBound($aItems) - 1 $x += $aArray[$aItems[$i]][1] Next _ArrayAdd($outArray , $aArray[$k][0] & "|" & ($x / ubound($aItems))) _ArrayInsert($aItems , 0 , ubound($aItems)) _ArrayDelete($aArray , $aItems) $k -= ubound($aItems) - 1 next _ArraySort($outArray) _ArrayDisplay($outArray)
    1 point
  6. Bundle version 2.2 released, with @Deye's highly useful UDF filtering mod incorporated (many thanks once again for that, Deye! ), plus the (still somewhat experimental) storeCCprofile utility, with which one can extract all key definition responses on a target machine (encrypted) on a USB stick, to be uploaded on your own machine for CodeCrypter to generate an encrypted script that'll run only on that target machine (provided you're using hardware-specific keys, of course). Still with me? Not only does this facilitate the process for single keys (which you no longer have to type in twice in the dialog under the Decryptor Button), but also enables multi-key cycling for machines other than the one Codecrypter is running on, as the entire CCkey array from the target machine is now available after pressing the new "Profile" button, which uploads the (decrypted) contents of the profile.mcf file on your USB stick. Note that if you change the key definitions in MCFinclude.au3, you'll need to re-compile storeCCkey.au3 (which #includes MCFinclude.au3) as well.
    1 point
  7. to wakillon Thanx for the adjustment. I didn't test it for No files. #include <file.au3> #include <array.au3> #include <date.au3> $_FileDeleteByAge = _FileDeleteByAge ( @TempDir, "~DF*.tmp", 24, 0 ) ConsoleWrite ( "-->-- @error : " & @error & @Crlf ) ConsoleWrite ( "-->-- Files Delete By Age : " & $_FileDeleteByAge & @Crlf ) ;====================================================================== ; _FileDeleteByAge ; Author Roland Raijmakers ; Date 28-2-2011 ; Change: Error Handler by Wakillon 1-3-2011 ; Parameters $Path : Path to files ; $FileMask : File mask for files to be deleted ; $Age : Minimum Age (in hours) before files are deleted ; $FileRetention : Number of Files to be kept ; Function Deletes files in $FileMask to be deleted. ; Intented to cleanup old log, bak and tmp files ; There are two triggers before a file is deleted, $Age (in hours) and $FileRetention ; If both are met then a file is deleted. ; Return Values: ; @Error -1 No files found ; 0 or greater number Non-Deleted files ; Return No of deleted Files Func _FileDeleteByAge ( $Path, $FileMask="*.*", $Age=14, $FileRetention=0 ) Local $t[10], $Files2[1][4] Local $Date, $FileCount, $_FileTotDelete=0, $_NotDeleted=0 $Now = _NowCalc() $Files = _FileListToArray($Path, $FileMask, 1) If Not @error Then $FileCount = ubound($Files)-1 Redim $Files2[$FileCount+1][4] $Files2[0][0]=$FileCount For $i = 1 To $FileCount $t = FileGetTime($Path & "\" & $Files[$i], 0, 0) $Date = StringFormat("%02i/%02i/%02i %02i:%02i:%02i", $t[0], $t[1], $t[2], $t[3], $t[4], $t[5]) $Files2[$i][0] = $Files[$i] $Files2[$i][1] = $Date $Files2[$i][2] = _DateDiff('H', $Date, $Now) Next _Arraysort($Files2,1,1,0,1) ;Sort Array Ascending on column 1 with row 0 For $i = 1 To $FileCount If $i > $FileRetention And $Files2[$i][2] > $Age Then $_FileTotDelete += 1 $Files2[$i][3] = "DELETE" $_FileDelete = FileDelete($Path & "\" & $Files2[$i][0]) If Not $_FileDelete Then $_NotDeleted += 1 Endif Next SetError ( $_NotDeleted ) Return $_FileTotDelete - $_NotDeleted Endif SetError ( -1 ) EndFunc ;==> _FileDeleteByAge ( )
    1 point
×
×
  • Create New...