Remove parts of text out of txt file

Discuss RoboTask here
rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Remove parts of text out of txt file

Post by rice1973 »

Hello Oleg,

I made a filcompare with "FC" this is the syntax;

fc stock900.txt stock1000.txt > test.txt

this is the output

Comparing files stock900.txt and STOCK1000.TXT
***** stock900.txt
filiaal,sku,stock.qty,stock.is_in_stock
"1","010052270112","0","0"
"1","010059870113","0","0"
***** STOCK1000.TXT
filiaal,sku,stock.qty,stock.is_in_stock
"1","010052270112","1000","0"
"1","010059870113","0","0"
*****

Now i need to "cut" out of the test.txt file;


Comparing files stock900.txt and STOCK1000.TXT
***** stock900.txt
filiaal,sku,stock.qty,stock.is_in_stock
"1","010052270112","0","0"
"1","010059870113","0","0"
***** STOCK1000.TXT


and the five stars at the end;

*****

So only this is the result;

"1","010052270112","1000","0"
"1","010059870113","0","0"

The number of lines in the fc result can vary.
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Remove parts of text out of txt file

Post by Oleg »

In other words you need to keep only lines between
***** STOCK1000.TXT
filiaal,sku,stock.qty,stock.is_in_stock

and

*****

Is this correct?
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Remove parts of text out of txt file

Post by Oleg »

Look at this example, please:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1597096124
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task34"
Hide=INTEGER|0
ID=INTEGER|1533792724
LocalVariables=STRING|"part"
LogOnAsUser=INTEGER|1
Name=STRING|"Extract part of text"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER

[Actions\Action1]
ActionID=STRING|"A_REGEXP_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"RegExp Replace"
Params=FOLDER

[Actions\Action1\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"Comparing files stock900.txt and STOCK1000.TXT "
line00000001=STRING|"***** stock900.txt "
line00000002=STRING|"filiaal,sku,stock.qty,stock.is_in_stock "
line00000003=STRING|"""1"",""010052270112"",""0"",""0"" "
line00000004=STRING|"""1"",""010059870113"",""0"",""0"" "
line00000005=STRING|"***** STOCK1000.TXT "
line00000006=STRING|"filiaal,sku,stock.qty,stock.is_in_stock "
line00000007=STRING|"""1"",""010052270112"",""1000"",""0"" "
line00000008=STRING|"""1"",""010059870113"",""0"",""0"" "
line00000009=STRING|"""1"",""010059870113"",""0"",""0"" "
line0000000A=STRING|"""1"",""010059870113"",""0"",""0"" "
line0000000B=STRING|"""1"",""010059870113"",""0"",""0"" "
line0000000C=STRING|"""1"",""010059870113"",""0"",""0"" "
line0000000D=STRING|"***** "
linecount=STRING|"14"
multiline=STRING|"1"
noautocapture=STRING|"0"
pattern=STRING|"(.+)(\*\*\*\*\* STOCK1000\.TXT[ ]*$)(.+)(\*\*\*\*\*[ ]*$)"
replacementcount=STRING|"0"
repline00000000=STRING|"$3"
replinecount=STRING|"1"
singleline=STRING|"1"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"part"

[Actions\Action2]
ActionID=STRING|"A_STR_TRIM"
Enabled=INTEGER|-1
Name=STRING|"STR Trim"
Params=FOLDER

[Actions\Action2\Params]
custom=STRING|"0"
eol=STRING|"1"
lead=STRING|"1"
source=STRING|"{part}"
spaces=STRING|"1"
tabs=STRING|"1"
trailing=STRING|"1"
variable=STRING|"part"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{part}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"{part}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_REGEXP_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"RegExp Replace"
Params=FOLDER

[Actions\Action4\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{part}"
linecount=STRING|"1"
multiline=STRING|"1"
noautocapture=STRING|"0"
pattern=STRING|"^filiaal.*$"
replacementcount=STRING|"0"
replinecount=STRING|"0"
singleline=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"part"

[Actions\Action5]
ActionID=STRING|"A_STR_TRIM"
Enabled=INTEGER|-1
Name=STRING|"STR Trim"
Params=FOLDER

[Actions\Action5\Params]
custom=STRING|"0"
eol=STRING|"1"
lead=STRING|"1"
source=STRING|"{part}"
spaces=STRING|"1"
tabs=STRING|"1"
trailing=STRING|"1"
variable=STRING|"part"

[Actions\Action6]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{part}"""
Params=FOLDER

[Actions\Action6\Params]
icon=STRING|"1"
msg0=STRING|"{part}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Remove parts of text out of txt file

Post by rice1973 »

Hello Oleg,

New problem, the file can also be like this;

Comparing files stock900.txt and STOCK1000.TXT
***** stock900.txt
filiaal,sku,stock.qty,stock.is_in_stock
"1","010052270112","0","0"
"1","010059870113","0","0"
***** STOCK1000.TXT
filiaal,sku,stock.qty,stock.is_in_stock
"1","010052270112","1000","0"
"1","010059870113","0","0"
*****

***** stock900.txt
"1","010107750105","1","1"
"1","010090460113","0","0"

***** STOCK1000.TXT
"1","010107750105","1","1"
"1","010090460113","500","0"

*****

Thebn your solution does not work.. :(
rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Remove parts of text out of txt file

Post by rice1973 »

In the basic i need to compare 2 files.

But the FC command is not good for that...... :(
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Remove parts of text out of txt file

Post by Oleg »

What strings do you want to extract?
I think all information lines in STOCK1000.TXT.
like this:
"1","010052270112","1000","0"
"1","010059870113","0","0"
"1","010107750105","1","1"
"1","010090460113","500","0"

Correct?
I'll try to solve.
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Remove parts of text out of txt file

Post by Oleg »

In the basic i need to compare 2 files.

But the FC command is not good for that...... :(
FC compares files and gives you differences as text with examples. What result do you want to obtain?
rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Remove parts of text out of txt file

Post by rice1973 »

"file 1" and "file 2"

After compare i only want to see the different lines with
the lines of "file 2" in it.
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Remove parts of text out of txt file

Post by Oleg »

See improved example:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1597096124
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task34"
Hide=INTEGER|0
ID=INTEGER|1533792724
LocalVariables=STRING|"part,newtext,found"
LogOnAsUser=INTEGER|1
Name=STRING|"Extract all parts of comparison"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_REGEXP_LOOP"
Enabled=INTEGER|-1
Name=STRING|"RegExp Loop"
Params=FOLDER

[Actions\Action1\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"Comparing files stock900.txt and STOCK1000.TXT "
line00000001=STRING|"***** stock900.txt "
line00000002=STRING|"filiaal,sku,stock.qty,stock.is_in_stock "
line00000003=STRING|"""1"",""010052270112"",""0"",""0"" "
line00000004=STRING|"""1"",""010059870113"",""0"",""0"" "
line00000005=STRING|"***** STOCK1000.TXT "
line00000006=STRING|"filiaal,sku,stock.qty,stock.is_in_stock "
line00000007=STRING|"""1"",""010052270112"",""1000"",""0"" "
line00000008=STRING|"""1"",""010059870113"",""0"",""0"" "
line00000009=STRING|"***** "
line0000000B=STRING|"***** stock900.txt "
line0000000C=STRING|"""1"",""010107750105"",""1"",""1"" "
line0000000D=STRING|"""1"",""010090460113"",""0"",""0"" "
line0000000F=STRING|"***** STOCK1000.TXT "
line00000010=STRING|"""1"",""010107750105"",""1"",""1"" "
line00000011=STRING|"""1"",""010090460113"",""500"",""0"" "
line00000013=STRING|"***** "
line00000016=STRING|"***** stock900.txt "
line00000017=STRING|"""1"",""010107750105"",""1"",""1"" "
line00000018=STRING|"""1"",""010090460113"",""0"",""0"" "
line0000001A=STRING|"***** STOCK1000.TXT "
line0000001B=STRING|"""1"",""010107750105"",""1"",""1"" "
line0000001C=STRING|"""1"",""010090460113"",""500"",""2"" "
line0000001D=STRING|"""1"",""010107750105"",""1"",""3"" "
line0000001E=STRING|"""1"",""010090460113"",""500"",""4"" "
line0000001F=STRING|"""1"",""010107750105"",""1"",""5"" "
line00000020=STRING|"""1"",""010090460113"",""500"",""5"" "
line00000022=STRING|"***** "
linecount=STRING|"35"
multiline=STRING|"1"
noautocapture=STRING|"0"
pattern=STRING|"\*\*\*\*\* STOCK1000\.TXT[ ]*$(.+)\*\*\*\*\*[ ]*$"
savelengths=STRING|"0"
saveoffsets=STRING|"0"
singleline=STRING|"1"
ungreedy=STRING|"1"
useexternal=STRING|"0"
variable=STRING|"part"

[Actions\Action10]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWTEXT"" with value ""{NewText}{part}{eol}"""
Params=FOLDER

[Actions\Action10\Params]
expand=STRING|"1"
varname=STRING|"NEWTEXT"
varvalue=STRING|"{NewText}{part}{eol}"

[Actions\Action11]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{NewText}"""
Params=FOLDER

[Actions\Action12\Params]
icon=STRING|"1"
msg0=STRING|"{NewText}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_STR_TRIM"
Enabled=INTEGER|-1
Name=STRING|"STR Trim"
Params=FOLDER

[Actions\Action2\Params]
custom=STRING|"0"
eol=STRING|"1"
lead=STRING|"1"
source=STRING|"{part(1)}"
spaces=STRING|"1"
tabs=STRING|"1"
trailing=STRING|"1"
variable=STRING|"part"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{part}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"{part}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER

[Actions\Action4\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{part}"
linecount=STRING|"1"
multiline=STRING|"1"
noautocapture=STRING|"0"
pattern=STRING|"^filiaal"
savesubexpression=STRING|"0"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"

[Actions\Action5]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action5\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{found}"

[Actions\Action6]
ActionID=STRING|"A_REGEXP_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"RegExp Replace"
Params=FOLDER

[Actions\Action6\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{part}"
linecount=STRING|"1"
multiline=STRING|"1"
noautocapture=STRING|"0"
pattern=STRING|"(filiaal.*$)(.+)"
replacementcount=STRING|"0"
repline00000000=STRING|"$3"
replinecount=STRING|"1"
singleline=STRING|"1"
ungreedy=STRING|"1"
useexternal=STRING|"0"
variable=STRING|"part"

[Actions\Action7]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action8]
ActionID=STRING|"A_STR_TRIM"
Enabled=INTEGER|-1
Name=STRING|"STR Trim"
Params=FOLDER

[Actions\Action8\Params]
custom=STRING|"0"
eol=STRING|"1"
lead=STRING|"1"
source=STRING|"{part}"
spaces=STRING|"1"
tabs=STRING|"1"
trailing=STRING|"1"
variable=STRING|"part"

[Actions\Action9]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{part}"""
Params=FOLDER

[Actions\Action9\Params]
icon=STRING|"1"
msg0=STRING|"{part}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Remove parts of text out of txt file

Post by rice1973 »

Hello Oleg,

Just send you an email on info@robotask.com with the files
to explain.

sender: info@mjbprojects.nl
Post Reply