vinnyMS Posted May 17, 2021 Share Posted May 17, 2021 #Include <Array.au3> #include <Constants.au3> $s = FileRead("2.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _ArrayDisplay($w) i have this script that returns 3 columns i need to copy the Col 0 and Col 1 as text to paste on notepad or excel you will have to create a "copy" button if possible array.au3 2.txt Link to comment Share on other sites More sharing options...
pseakins Posted May 17, 2021 Share Posted May 17, 2021 19 minutes ago, vinnyMS said: you will have to create a "copy" button if possible Not me, YOU, will have to create a copy button. This addition to your code will write the required output which you can then open in notepad or import into excel. Or, you can insert it into your clipboard buffer using ClipPut(). $sOut = "" For $i = 0 To UBound($w) - 1 $sOut = $sOut & $w[$i][0] & @TAB & $w[$i][1] & @CRLF Next FileWrite("2out.txt", $sOut) vinnyMS 1 Phil Seakins Link to comment Share on other sites More sharing options...
JockoDundee Posted May 17, 2021 Share Posted May 17, 2021 9 hours ago, pseakins said: Not me, YOU, will have to create a copy button. Obviously you’ve never met VinnyMS before pseakins 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Danp2 Posted May 17, 2021 Share Posted May 17, 2021 Take a look at _DebugArrayDisplay vinnyMS 1 WebDriver UDF [GH&S] Latest version Wiki FAQs Link to comment Share on other sites More sharing options...
pixelsearch Posted May 17, 2021 Share Posted May 17, 2021 (edited) Just use _DebugArrayDisplay instead of _ArrayDisplay, you'll find 2 copy buttons that will copy the results in the Clipboard * Results are whole columns if no row is selected. * If you select some lines, then only the selected lines are copied * If your display retrieved for example 10 columns and you want to copy only columns 0-1, then use the array range param. (3rd param) to display only 2 columns _DebugArrayDisplay($w, "Title", "|0:1") * If you don't want the "Row column" to appear, just add the correct 4th param. _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) This will do it : #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> $s = FileRead("2.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w) ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) Edit: While I was writing this, DanP2 just said it too Edited May 17, 2021 by pixelsearch vinnyMS and Danp2 1 1 Link to comment Share on other sites More sharing options...
vinnyMS Posted May 18, 2021 Author Share Posted May 18, 2021 Thank you all If the text is "- 5679.01" It lists "5679" only Can someone fix it Link to comment Share on other sites More sharing options...
Danp2 Posted May 18, 2021 Share Posted May 18, 2021 46 minutes ago, vinnyMS said: It lists "5679" only You really should make more of an effort to provide a detailed description of your issue. As it is, I have no idea what "it" is. FWIW, I'm not experiencing any issues when running this short example -- #include <Debug.au3> ; Create 1D array to display Local $aArray_1D[5] = [-5679.01, -5679.011, -5679.012, -5679.013, -5679.014] _DebugArrayDisplay($aArray_1D, "1D display") WebDriver UDF [GH&S] Latest version Wiki FAQs Link to comment Share on other sites More sharing options...
JockoDundee Posted May 18, 2021 Share Posted May 18, 2021 14 minutes ago, Danp2 said: FWIW, I'm not experiencing any issues when running this short example -- Actually, he’s got a space in there "- 5679.01" Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
vinnyMS Posted May 19, 2021 Author Share Posted May 19, 2021 56 minutes ago, Danp2 said: You really should make more of an effort to provide a detailed description of your issue. As it is, I have no idea what "it" is. FWIW, I'm not experiencing any issues when running this short example -- #include <Debug.au3> ; Create 1D array to display Local $aArray_1D[5] = [-5679.01, -5679.011, -5679.012, -5679.013, -5679.014] _DebugArrayDisplay($aArray_1D, "1D display") i have attached the text file 2.txt Link to comment Share on other sites More sharing options...
vinnyMS Posted May 19, 2021 Author Share Posted May 19, 2021 need exact numbers with operator and decimal on the Array display Link to comment Share on other sites More sharing options...
pseakins Posted May 19, 2021 Share Posted May 19, 2021 53 minutes ago, vinnyMS said: need exact numbers with operator and decimal on the Array display There is a problem with your regexp but I can't help you with that. Outside my area of expertise. #include <File.au3> ;.. ;.. _FileReadToArray("2.txt", $s, 0, @TAB) This will give you an array that is undistorted Phil Seakins Link to comment Share on other sites More sharing options...
pseakins Posted May 19, 2021 Share Posted May 19, 2021 This does something like you want, but unsure what you want to do with the duplicates. You can delete them in a loop if required. $as1 = '' _FileReadToArray("2.txt", $as1, 0, @TAB) Local $s[UBound($as1, 2)] ; for 1D array ;Local $s[UBound($as1, 2)][2] ; for 2D For $i = 0 To UBound($as1, 2) - 1 ;$s[$i][0] = $as1[0][$i] ; 2D ;$s[$i][1] = $i ; 2D $s[$i] = $as1[0][$i] ; 1D Next $as1 = "" _ArraySort($s) ; dups NOT deleted or counted _ArrayDisplay($s) Phil Seakins Link to comment Share on other sites More sharing options...
vinnyMS Posted May 19, 2021 Author Share Posted May 19, 2021 Hopefully the regexp can be fixed Link to comment Share on other sites More sharing options...
pixelsearch Posted May 19, 2021 Share Posted May 19, 2021 Hello, I would have done it like this : #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> $s = FileRead("2.txt") ;~ Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) Local $w = StringRegExp($s, '(?s)(\-?\.?\d+\b)(?!.*\1\b)', 3) _DebugArrayDisplay($w, "1") _ArrayColInsert($w, 1) _DebugArrayDisplay($w, "2") For $i = 0 to UBound($w)-1 ;~ StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) StringRegExpReplace($s, '(?s)' & StringReplace($w[$i][0], ".", "\.") , "") $w[$i][1] = @extended Next _DebugArrayDisplay($w, "3") _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w, "4") Link to comment Share on other sites More sharing options...
JockoDundee Posted May 19, 2021 Share Posted May 19, 2021 3 hours ago, vinnyMS said: Hopefully the regexp can be fixed Where did the regex even come from? Just do this: #include <Array.au3> #include <Debug.au3> Local $aNums = StringSplit(FileRead("2.txt"), @TAB, 2) _ArraySort($aNums) _ArrayAdd($aNums, "") Local $aNumsO[Ubound($aNums)][2] Local $iMatches=1, $m=0 For $n = 1 To Ubound($aNums)-1 If $aNums[$n] = $aNums[$n-1] Then $iMatches+=1 Else $aNumsO[$m][0]=$aNums[$n-1] $aNumsO[$m][1]=$iMatches $iMatches=1 $m+=1 EndIf Next $aNumsO[$m][0]=$aNums[$n-1] $aNumsO[$m][1]=$iMatches Redim $aNumsO[$m][2] _ArraySort($aNumsO, 1, 0, 0, 1) _DebugArrayDisplay($aNumsO) Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
vinnyMS Posted May 20, 2021 Author Share Posted May 20, 2021 thanks a lot it works 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