Help to capture data vertically

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Help to capture data vertically

15 Nov 2017, 11:29

I am trying to capture specific text from the vertical data but unable to do that. No idea how to use RegExMatch here.

I need colored data in horizontal lines. Like below format

ABC XYZ "`t" 89 "`t" Update Request: Dummy, Dummy1 "`t" Pending "`t" Sender "`t" 11/05/2017 "`t"

ABC XYZ "`t" 45 "`t" Update Request: Dummy, Dummy2 "`t" Pending "`t" Sender "`t" 11/15/2017 "`t"

Here ABC XYZ (start value) and 11/15/2017 (end value) is unique value but i have no idea how to capture this and convert in desire format.
Create New Request...
Select one or more rows in your sheet to create a new Update Request.Scheduled
Sent To
Rows
Subject
From
Last Sent
Next Send
Sent To
Rows
Subject
From
Last Sent
Next Send
Pending/Completed
Sent To
Rows
Subject
Status
From
Sent
Sent To
Rows
Subject
Status
From
Sent
ABC XYZ
89
Update Request: Dummy, Dummy1
Pending
Sender
11/05/2017

ABC XYZ
45
Update Request: Dummy, Dummy2
Pending
Sender
11/15/2017

ABC XYZ
44
Update Request: Dummy, Dummy3
Pending
Sender
11/08/2017

ABC XYZ
43
Update Request: Dummy, Dummy4
Pending
Sender
11/15/2017
User avatar
Gio
Posts: 1247
Joined: 30 Sep 2013, 10:54
Location: Brazil

Re: Help to capture data vertically

15 Nov 2017, 12:03

Hello Pardeep Tariyal.

I would set the RegExMatch() like this (pseudo-code): "ABCSpaceXYZ followed by anything up to the first occurence of NumberNumber/NumberNumber/NumberNumberNumberNumber"

Thus, it would go like this:

Code: Select all

var = 
(
Create New Request...
Select one or more rows in your sheet to create a new Update Request.Scheduled
Sent To
Rows
Subject
From
Last Sent
Next Send
Sent To
Rows
Subject
From
Last Sent
Next Send
Pending/Completed
Sent To
Rows
Subject
Status
From
Sent
Sent To
Rows
Subject
Status
From
Sent
ABC XYZ
89
Update Request: Dummy, Dummy1
Pending
Sender
11/05/2017
ABC XYZ
45
Update Request: Dummy, Dummy2
Pending
Sender
11/15/2017
ABC XYZ
44
Update Request: Dummy, Dummy3
Pending
Sender
11/08/2017
ABC XYZ
43
Update Request: Dummy, Dummy4
Pending
Sender
11/15/2017
)

Result := RegExMatch(var, "s)ABC XYZ.*?\d\d\/\d\d\/\d\d\d\d", OutputVar)
msgbox % OutPutVar
Also, if you wish to collect ALL matching entries from the same haystack, just do this: create a copy of the haystack, operate the RegExMatch() on that copy, trim (StringTrimLeft) the characters of the copy of Haystack up to the position indicated in the returned Result of RegExMatch() + 1, than do the RegExMatch() on the remaining string again to collect a second sample, than trim the copy again up to the returned position + 1, and so on untill the RegExMatch() finds no more matches in the remaining characters of the copy. This could be done with a while loop, and the matches could be saved to indexed variable names with the aid of the A_Index built-in variable.

If you need further help on implementating the above, feel free to ask.
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Help to capture data vertically

15 Nov 2017, 12:10

give this a try

Code: Select all

inputstring := "
(
Create New Request...
Select one or more rows in your sheet to create a new Update Request.Scheduled
Sent To
Rows
Subject
From
Last Sent
Next Send
Sent To
Rows
Subject
From
Last Sent
Next Send
Pending/Completed
Sent To
Rows
Subject
Status
From
Sent
Sent To
Rows
Subject
Status
From
Sent
ABC XYZ
89
Update Request: Dummy, Dummy1
Pending
Sender
11/05/2017
ABC XYZ
45
Update Request: Dummy, Dummy2
Pending
Sender
11/15/2017
ABC XYZ
44
Update Request: Dummy, Dummy3
Pending
Sender
11/08/2017
ABC XYZ
43
Update Request: Dummy, Dummy4
Pending
Sender
11/15/2017
)"


xpos := 1
lineout := []
While(RegExMatch(inputstring, "OUm)(ABC.*)(?=ABC|$)", var, xpos)) {
   xpos := var.Pos(1) + var.Len(1)
   lineout.push(RegExReplace(var[1],"`n","`t"))
}
for k, v in lineout
   strou .= v "`n"
clipboard := strou
MsgBox %strou%
ExitApp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

17 Nov 2017, 05:41

Odlanir wrote:give this a try

Code: Select all

inputstring := "
(
Create New Request...
Select one or more rows in your sheet to create a new Update Request.Scheduled
Sent To
Rows
Subject
From
Last Sent
Next Send
Sent To
Rows
Subject
From
Last Sent
Next Send
Pending/Completed
Sent To
Rows
Subject
Status
From
Sent
Sent To
Rows
Subject
Status
From
Sent
ABC XYZ
89
Update Request: Dummy, Dummy1
Pending
Sender
11/05/2017
ABC XYZ
45
Update Request: Dummy, Dummy2
Pending
Sender
11/15/2017
ABC XYZ
44
Update Request: Dummy, Dummy3
Pending
Sender
11/08/2017
ABC XYZ
43
Update Request: Dummy, Dummy4
Pending
Sender
11/15/2017
)"


xpos := 1
lineout := []
While(RegExMatch(inputstring, "OUm)(ABC.*)(?=ABC|$)", var, xpos)) {
   xpos := var.Pos(1) + var.Len(1)
   lineout.push(RegExReplace(var[1],"`n","`t"))
}
for k, v in lineout
   strou .= v "`n"
clipboard := strou
MsgBox %strou%
ExitApp
Thank to help me but its not working while i am replacing data to variable. Like inputstring = %Clipbaord%
User avatar
Micromegas
Posts: 260
Joined: 28 Apr 2015, 23:02
Location: Germany

Re: Help to capture data vertically

23 Nov 2017, 05:20

Maybe it wasn't working because you misspelled the name %Clipboard%? Have you tried the correct spelling?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, gsxr1300, mikeyww, PsysimSV and 286 guests