Page 1 of 1

Copy part of text between ""

Posted: 21 Jan 2021, 06:17
by hajen101
Can someone please help me with this problem. I have text lines like this that i want to copy. But only copy and paste "Two", then copy and paste "Three", and move on to "Four" copy and paste, then copy and paste "five", And when that is done it shall move on to the next line.

"one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"

I know how to copy whole lines or text files but not just part of some txt

If someone knows how to do please respond

Re: Copy part of text between ""

Posted: 21 Jan 2021, 06:40
by mikeyww

Code: Select all

str =
(
"one";"Two";"Three"
"four";"five";"6"
)
item := StrSplit(StrReplace(str, "`n", ";"), ";")
F3::Send % StrReplace(item.RemoveAt(1), """")

Re: Copy part of text between ""

Posted: 21 Jan 2021, 07:26
by garry
@mikeyww your example works fine , maybe stop sending when finished
question : just copy a part from line and then continue next line ( e.g. two,three,five and then next line )

Re: Copy part of text between ""

Posted: 21 Jan 2021, 07:57
by mikeyww

Code: Select all

str =
(
"1one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"2one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
)
item := []
Loop, Parse, str, `n 
 For k, v in StrSplit(RegExReplace(A_LoopField, "(.*?;){4}.*?\K;.*"), ";")
  item.Push(StrReplace(v, """"))
F3::
If !item.Count() {
 MsgBox, 48, Done, Nothing left!
 Return
}
SendInput % item.RemoveAt(1)
If !item.Count()
 MsgBox, 64, Success, Done!
Return

Re: Copy part of text between ""

Posted: 21 Jan 2021, 14:44
by garry
@mikeyww thank you , a last question :
example a csv file with 1000 rows and woul'd rearrange the columns ( 1,2,3,4,5,6,7,8,9,10 ) , new > show columns 8,6,4,9 ( or all columns with a different order / maybe I use another delimiter / make a new file )

Re: Copy part of text between ""

Posted: 21 Jan 2021, 15:01
by mikeyww
You could StrSplit or Loop, Parse the entire line, using ; as the delimiter, and then just use the parts that you want.

Re: Copy part of text between ""

Posted: 21 Jan 2021, 15:18
by garry
@mikeyww thank you , your solutions were always professional

Re: Copy part of text between ""

Posted: 22 Jan 2021, 03:30
by hajen101
Thanks i will try this later today :-)
The original part of lines look like this

* * * *
"1295058995";"1044721011064";"1909142087";"Glue";"26101";"48,00";"79,92";"99,9";"FRP";"FRP";"GL"

And the * is the parts i want to copy and paste into another program.
And i have a text file with multiply lines that looks like this :D

Thanks for all your help.

Re: Copy part of text between ""

Posted: 22 Jan 2021, 05:17
by garry
@hajen101 you want copy only some columns which is marked with '*' ( I didn't see marked columns , you mean the first 4 columns ? ) , mikeyww has above a script to see the first 5 columns
or , you mean you want the next row after the row * * * * ?
* * * *
"1295058995";"1044721011064";"1909142087";"Glue";"26101";"48,00";"79,92";"99,9";"FRP";"FRP";"GL"
And the * is the parts i want to copy and paste into another program.

Re: Copy part of text between ""

Posted: 22 Jan 2021, 06:35
by mikeyww
Here's an update for four values if you like.

Code: Select all

numberOfColumns := 4
str =
(
"1one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
"2one";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine";"Ten";"Eleven"
)
item := []
Loop, Parse, str, `n 
 For k, v in StrSplit(RegExReplace(A_LoopField, "(.*?;){" numberOfColumns - 1 "}.*?\K;.*"), ";")
  item.Push(StrReplace(v, """"))
F3::
If !item.Count() {
 MsgBox, 48, Done, Nothing left!
 Return
}
SendInput % item.RemoveAt(1)
If !item.Count()
 MsgBox, 64, Success, Done!
Return