amdogelover Posted November 29, 2016 Share Posted November 29, 2016 Hello guys, First of all, I received help on a very similar topic earlier and I tried to re-use that code for this but it doesn't work. That topic was: https://www.autoitscript.com/forum/topic/178976-copy-numbers-from-one-txt-to-another-using-stringregexp/ I tried using the bulk of that code to do to a similar thing: From within a function: DirCreate($katalog\b) FileMove("a\*.csv", $katalog & "\b\") _read_from_file_to_res("abc", $text, $res) I call my read-function: Func _read_from_file_to_res($id, $text, $res) If $id = "abc" And $res = "1" Then $fromSourceOpen = FileOpen($katalog & "b\*.csv") $fromSourceRead = FileRead($fromSourceOpen) $averageFpsVal = StringRegExp($fromSourceRead, '"Average FPS:"(\s+"\d+")', 1) $minimumFpsVal = StringRegExp($fromSourceRead, '"Min FPS:"(\s+"\d+")', 1) FileClose($fromSourceOpen) FileWriteLine($katalog & "\res.txt", "abc" & $text & " AVG: " & $averageFpsVal[0]) FileWriteLine($katalog & "\res.txt", "abc" & $text & " MIN: " & $minimumFpsVal[0]) EndIf EndFunc NOTE: I edited the code to hide a few names. What this should do is open the *.csv and find "Average FPS:" and save whatever follows after the white-lines that is a digital number into the $variable, and then write that value to the *.txt file. When I ran a similar code earlier I only got zeros ("0") but now I get an error instead (subscript used on a non-accessible variable) On to what I'm trying to do: I want to run a few tests that output a file with the results. I want to copy these results and save them to another file, and later (I haven't gotten this far), I want to sum the average of the values that have the same "id". I want to do this with three different tests, their respective output looks like this: Test 1: ... Min FPS: xx.x Average FPS: xx.x ... Test 2: ... Average FPS: xx.x Min FPS: xx.x ... Test 3 (only interested in first and third values): ... Pass 0 xx.x, xx.x, xx.x Pass 1 xx.x, xx.x, xx.x Pass 2 xx.x, xx.x, xx.x Pass 3 xx.x, xx.x, xx.x Pass 3 xx.x, xx.x, xx.x ... My question is, what do I do wrong and how can I fix the "pattern" for StringRegExp? Is there a way to write a pattern that encapsulates all three tests? How do I go about to sum the average of the results that I have just copied over to a new file (something like: read file, if name is same, copy value after ":" to array, sum array, write new line). And lastly, this is not work related or something I make money out of, it's a hobby of benchmarking. I've tried searching the forums and I've read the help files and doc on StringRegExp but nothing helped. Thanks for the help in advance. 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