Filter_Lines

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > TXT. Text-File Engine > CSV-Related Commands >

Filter_Lines

TXT.gdit

Previous Top Next


MiniRobotLanguage (MRL)

 

TXT.flt

TXT.Filter_Lines
Only keep Lines that contain specified Words in a specified Column.

 

 

Intention

 

This command is useful if you have to do with csv-files. Assume you have a List with Members of an Organisation.

Now you want to only keep certain Members in your Result List, for example those from a specified Country and with specified Occupation.

Like this one: WEF-Members (Internet-Link)

 

In Column "F" there you can read the profession, and in Column "L" the Country. Like this: (Sample)

 

clip0378

 

Now you just want all "Politician" and other "Actors" from "Germany" or "Poland".

This is the Script (active Part, full Script see below at Example):

 

$$IND="L"

$$SEA="Germany","Poland"

$$STA=2

$$DEL=;

' We use Stadard Search Pattern

TXT.flt|$$IND|$$SEA|$$STA|$$DEL|w

TXT.dbp

 

$$IND="F"

$$SEA="Politician","Actor"

$$STA=2

$$$DEL=;

' We use Stadard Search Pattern

TXT.flt|$$IND|$$SEA|$$STA|$$DEL|e

 

Here is a Part of the Result.

 

clip0379

 

 

Syntax

 

 

TXT.flt|P1|P2[|P3]

TXT.Filter_Lines|P1|P2[|P3]

 

 

Parameter Explanation

 

P1 - (Input) Column number which must contain the specified words in P3.

P2 - (Input) Variable with List of item to search for.The List must contain the words enclosed in "" and separated with ",".

                           Only Lines with any of the specified words in the Column P1 will be left in the final result.
                           Example:   "Fox","Wulf",Neutron"

P3 - (Input) Startline, if omitted default is 2 (to skip Headerline). First upper Line is Line 1. Lines before the Startline will be in the result untouched.

P4 - (Input) Variable with delimiter

P5 - (Input) Flag, can be any of these: "p" (default) - normal compare, "w" - compare using SPR-Standard-Search Patterns,

                           "e" - Equalcase Compare, "c" - contains, "ce" - contains equalcase, "x" - Exclusive Flag (do NOT list Lines before the Startline)

 

 

 

Example

 

'*****************************************************

'

'*****************************************************

' csv-File from: 

' https://maloneinstitute-org.translate.goog/wef?_x_tr_sl=en&_x_tr_tl=de&_x_tr_hl=de&_x_tr_pto=wapp

'

$$TMA=#dtime#

IEM.

  VAR.$$FIA=$cmdexe$

ELS.

  VAR.$$FIA=?exeloc\WEF-Members.CSV  

EIF.

VAR.$$OUF=?exeloc\Result_#date#.csv

NEF.$$FIA

  $$ERR=Die Quelldatei: $$FIA$crlf$existiert nicht.

  GTO.ero 

EIF.

'-----------------------------------------------------------

TXT.Load_Textfile|$$FIA|$$LIC

' Convert $LF to $crlf$ if needed.

'TXT.lfp

TXT.Get_Line_Count|$$LIC

IVV.$$LIC<5

  $$ERR=File is empty?

  GTO.ero

EIF.

PRT.$$LIC Lines loaded.

'++++++++++++++++++++++++++++++++

'++++++++++++++++++++++++++++++++

' Place your Script here

$$IND="L"

$$SEA="Germany","Poland"

$$STA=2

$$DEL=;

' We use Stadard Search Pattern

TXT.flt|$$IND|$$SEA|$$STA|$$DEL|w

TXT.dbp

 

$$IND="F"

$$SEA="Politician","Actor"

$$STA=2

$$$DEL=;

' We use Stadard Search Pattern

TXT.flt|$$IND|$$SEA|$$STA|$$DEL|e

 

'++++++++++++++++++++++++++++++++

'++++++++++++++++++++++++++++++++

' These lines process and save the result.

'TXT.lfr

TXT.Save_File|$$OUF

EXO.$$OUF

'++++++++++++++++++++++++++++++++

'++++++++++++++++++++++++++++++++

:enx

CAL.$$TMA=#dsince#*1000|i

IVV.$$TMA>1100

  CAL.$$TMA=$$$TMA/1000

  $$TXT=Programm wird beendet nach $$TMA Sekunden.

ELS.

  $$TXT=Programm wird beendet nach $$TMA ms.

EIF.

MBT.$$TXT|Programm Ende|9|32

ENR.

'-----------------------------------------------------------

:ero

PRT.$$ERR

GTO.enx

'#######################################################################

 

 

 

 

 

 

 

 

 

Remarks

 

-

 

Limitations:

 

-

 

 

See also:

 

  TXT.Load Textfile

  TXT.Clear

  TXT.From_Var

  TXT.Load_pure_Text

  TXT.Get_pure_Text

  FIL.Generate numbered Name

  FIL.Move numbered File

  ATF - Append-to-File

  CFF. - Copy-From-File

  CTF - Copy-To-File

  COP. - Copy File

  TXT.Get_Filename

  TXT.Get_Lenght

  TXT.To_Var_and_Clear

  GLC. - Get-Line-Count

  TXT.Get_Line

  IEF. / NEF. - If - exist - File

  LFF - Line-From-File

  WFF. - Wait-For-File

  TXT.Set_Line_to