Jump to content

Removing array cells. Words in cell reading.


Recommended Posts

Im working on my form filling bot.

Im using clippboard and arrays.

Row|Col 0
[0]| (must be deleted)
[1]| (must be deleted)
[2]| (must be deleted)
[3]| (must be deleted)
[4]| (must be deleted)
[5]| (must be deleted)
[6]| (must be deleted)
[7]| (must be deleted)
[8]| (must be deleted)
[9]| (must be deleted)
[10]|  HOME (must be deleted)
[11]| (must be deleted)
[12]| (must be deleted)
[13]|  FORUM (must be deleted)
[14]|  NEWS (must be deleted)
[15]| (must be deleted)
[16]| (must be deleted)
[17]| (must be deleted)
[18]| (must be deleted)
[19]|0 (must be deleted)
[20]|67 (must be deleted)
[21]|00 (must be deleted)
[22]|  (must be deleted)
[23]|Fried is a regional speciality (This changes)(always go separatly with +1 cell)
[24]|A cold blooded (<this 3 words i need in $searchfor) vertebrate animal that lives in water moving with the help of fins and breathing with gills  (This too changes size some time takes two cells, so array can change size)
[25]| (must be deleted)(this four cells always exist)
[26]| (must be deleted)
[27]| (must be deleted)
[28]| (must be deleted)

Sorry for mess. I need to automaticialy remove all cells that (must be deleted), resize array and move 3 first words of text from last existing cell into $searchfor.

Link to comment
Share on other sites

Row|Col 0
[0]|(this is not empty)
[1]|    (becouse of space; still must be removed)
[2]|  
[3]|  
[4]|    
[5]|    
[6]|   
[7]|0  (and i need to remove all numerical)
[8]|67
[9]|00
[10]|I really fish and chips.
[11]|A deep or abiding liking for something

This is what i get by using

$sText = FileRead("test.doc")

$sText = StringRegExpReplace(StringRegExpReplace($sText, "(\v)+", @CRLF), "\A\v|\v\Z", "")

$hFile = FileOpen("NewText.doc", 2)
FileWrite($hFile, $sText)
FileClose($hFile)

And i still have problem with spaces in array.

Ok. @mikell

I just refleshed topic and ill try some of your code.

Edited by polaski
Link to comment
Share on other sites

If speed is an issue then I wouldn't use _ArrayDelete but create a new array with only the needed cells.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Now from somthing like this

There are mistakes in your text. In fact, there aren't many mistakes in your text, but more than 2 or 3.
Consisting of a number more than two or three but not very many. (Wiktionnaire)

ive getting

Row|Col 0
[0]| [useless part beggins here]
  
  
  
 
0
67
00
There are mistakes [and ends here] 
Consisting of a  (this 3 words are my key)

Im really close to what i need.

Local $3words, $searchfor

  $3words = StringRegExpReplace($syf[$i], '\s*(\S+\s+\S+\s+\S+)\s.*', "$1")
   $searchfor &= $3words & @crlf
Next
Local $im[1]
$im[0] = $searchfor ;here im doing somthing rly bad...
;its just putting it in 1 string in array... i need to make it agin array cells.

_ArrayDisplay($im)

3rd EDIT:

Speed is not a problem. I dont need fast script.

 
The last cell of the array , will be the key to my search script
" Consisting of a " <search key word. So i need to get it out :D

Ok. Finally I can describe what I mean exactly .

In next post :D

 

 

Edited by polaski
Link to comment
Share on other sites

My script:

#include <Word.au3>
#include <File.au3>
#include <Clipboard.au3>
#include <Array.au3>





;;;;;;;;;;;;;;;;; Obsługa test.doc;;;;;;;;;;;;
if fileExists("test.doc")   then
   FileDelete("test.doc")
   EndIf
$demo = _ClipBoard_GetData($CF_TEXT)
FileWrite("test.doc", $demo )
FileClose("test.doc")

$wordholder = _Word_Create(false,false) ;pierwsza wartość na true widzialny word.
$sheetholder = _Word_DocOpen ( $wordholder, "test.doc" ) ;shietholder= $oDoc





_Word_DocSave ( $sheetholder )
_Word_DocClose ($sheetholder, $WdSaveChanges)
_Word_Quit($wordholder)

$sText = FileRead("test.doc")

$sText = StringRegExpReplace(StringRegExpReplace($sText, "(\v)+", @CRLF), "\A\v|\v\Z", "")

$hFile = FileOpen("NewText2.doc", 2)
FileWrite($hFile, $sText)
FileClose($hFile)



$syf = FileReadToArray ( "NewText2.doc" )
_ArrayDisplay($syf)
;Local $3words, $searchfor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;operacje na tablicy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;For $i = 0 to UBound($syf)-1
;  $3words = StringRegExpReplace($syf[$i], '\s*(\S+\s+\S+\s+\S+)\s.*', "$1")
;   $searchfor &= $3words & @crlf
;Next
;Local $im[1]
;$im[0] = $searchfor
#cs
Local $iDim = UBound($syf, $UBOUND_DIMENSIONS)
 For $i = 0 To $iDim - 1
      If StringIsDigit($syf[$i])= 1 Then
         _ArrayDelete($syf,$i)
      EndIf
      If StringIsFloat($syf[$i])= 1 Then
         _ArrayDelete($syf,$i)
      EndIf

Next

    If IsFloat($syf[$i])= 1 Then
         _ArrayDelete($syf,$i)
      EndIf
   Next

#ce



;_ArrayDisplay($im)





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;Operacje na schowku Clipboard;;;;;;;; widnowsa
;FileOpen("clipboard.txt", 2)

 

And.

 

So now u can see.

That the bigger Doc got deffinitions of words.

 

3rd EDIT

: EXTANDED CODE.

#include <Word.au3>
#include <File.au3>
#include <Clipboard.au3>
#include <Array.au3>



;;;;;;;;;;;;;;;;; Obsługa test.doc;;;;;;;;;;;;
if fileExists("test.doc")   then
   FileDelete("test.doc")
   EndIf
$demo = _ClipBoard_GetData($CF_TEXT)
FileWrite("test.doc", $demo )
FileClose("test.doc")

$wordholder = _Word_Create(false,false) ;pierwsza wartość na true widzialny word.
$sheetholder = _Word_DocOpen ( $wordholder, "test.doc" ) ;shietholder= $oDoc


;;;usówanie przeszkód;;;;;;
_Word_DocFindReplace( $sheetholder, "Summary test", "")
_Word_DocFindReplace( $sheetholder, "hint?", "")
_Word_DocFindReplace( $sheetholder, "HOME", "",1);
_Word_DocFindReplace( $sheetholder, "FORUM", "",1);
_Word_DocFindReplace( $sheetholder, "NEWS", "",1);


_Word_DocSave ( $sheetholder )
_Word_DocClose ($sheetholder, $WdSaveChanges)
_Word_Quit($wordholder)

$sText = FileRead("test.doc")

$sText = StringRegExpReplace(StringRegExpReplace($sText, "(\v)+", @CRLF), "\A\v|\v\Z", "")

$hFile = FileOpen("NewText2.doc", 2)
FileWrite($hFile, $sText)
FileClose($hFile)


$syf = FileReadToArray ( "NewText2.doc" )
;_ArrayDisplay($syf)

Local $3words, $searchfor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;operacje na tablicy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
For $i = 0 to UBound($syf)-1
  $3words = StringRegExpReplace($syf[$i], '\s*(\S+\s+\S+\s+\S+)\s.*', "$1")
   $searchfor &= $3words & @crlf
Next
;Local $im[1]
$hFile2 = FileOpen("NewText3.doc", 2)
FileWrite($hFile2, $searchfor)
FileClose($hFile2)

$syf2 = FileReadToArray ( "NewText3.doc" )
;$rozmiar = UBound($syf2)-1

Global $array1[1]
$array1[0] = $syf2[UBound($syf2)-1]
_ArrayDisplay($array1)

 

SO IT WORKS I`ve get an 1 cell Array with key words i need.

Row|Col 0
[0]|Various sounds usually


Problem SOLVED ty to mikell

Can be closed.

Edited by polaski
Link to comment
Share on other sites

#include <File.au3>
#include <Clipboard.au3>

;;;;;;;;;;;;;;;;; Obsługa test.txt;;;;;;;;;;;;
$hFile = FileOpen("test.txt", 2)
$demo = _ClipBoard_GetData($CF_TEXT)
FileWrite($hFile, $demo )
FileClose($hFile)

;;;;;;;;;4th part
$syf = FileReadToArray ( "test.txt" )

Local $3words, $searchfor
For $i = 0 to UBound($syf)-1
  $3words = StringRegExpReplace($syf[$i], '\s*(\S+\s+\S+\s+\S+)\s.*', "$1")
   $searchfor &= $3words & @crlf
Next

FileOpen("test.txt",2)
FileWrite($hFile, $searchfor)
FileClose($hFile)

Same code after delleting trash.

It cooperating with

#include <Array.au3>
#include <File.au3>
 #include <Clipboard.au3>

$klucz = FileReadToArray ( "test.txt" )
Global $array1[1]
$array1[0] = $klucz[UBound($klucz)-3]

$tablica = FileReadToArray ( "key.txt" ) ;key.txt is created by replacing "test.txt" in top script 

Global $odpowiedz[1]
For $i = 0 to UBound($tablica)-1
   if $array1[0] = $tablica[$i] Then
      $odpowiedz[0]=$tablica[$i-1]
      _ClipBoard_SetData($odpowiedz[0])
   _ArrayDisplay($odpowiedz)
   EndIf
Next

Topic can still be Closed
 

Edited by polaski
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...