Loading ...
Sorry, an error occurred while loading the content.

IF EXIST "expression" in TEXT FILE

Expand Messages
  • gp3@post.sk
    Hi, I have a huge problem. I have two text files, which are lists - one NEWLIST and one BIGLIST. I struggle to find a routine which will check the NEWLIST
    Message 1 of 5 , May 16, 2001
    • 0 Attachment
      Hi, I have a huge problem.

      I have two text files, which are lists - one NEWLIST and one BIGLIST.
      I struggle to find a routine which will check the NEWLIST whether the
      entries in NEWLIST are found in BIGLIST and return a remark, or put
      the lines, that are found in BIGLIST into another file, let's say
      DUPLICATES.

      The biggest problem for me is to write a routine that will check the
      lines in NEWLIST whether they are found in BIGLIST. I'd also like to
      use regular expressions.

      Example: the first line in BIGLIST would be "Toyota Paseo". I'd like
      to check whether there exists the line "Car Models:*Toyota Paseo*Car
      Specs", using reg.expr., as BIGLIS is structured like this

      Car Model: Toyota Celica TAB Car Specs: ...
      Car Model: Toyota Paseo TAB Car Specs: ...

      Then some kind of TRUE/FALSE output would be good, or simply pur a
      remark in fromt of the entry in NEWLIST, like this:

      Pontiac Firebird
      *Toyota Paseo
      Acure Vigor
      *Toyota Celica

      I would now know that I already have Paseo and Celica in my list.

      I hope I made my problem clear, please help me, this is too much for
      me at this time and I am in a hurry to make the clip work.

      Thanx in advance,
      mikey
    • Alan C.
      Hi mikey, ... did it without regex as I do not know regex a cut to the chase model of a clip it is at this point. nonetheless it worked good on enclosed
      Message 2 of 5 , May 17, 2001
      • 0 Attachment
        Hi mikey,

        >The biggest problem for me is to write a routine that will check the
        >lines in NEWLIST whether they are found in BIGLIST. I'd also like to
        >use regular expressions.

        did it without regex as I do not know regex

        a "cut to the chase" model of a clip it is at this point. nonetheless it worked good on enclosed samples.

        in the samples, the tab character/token is where you said, but I cannot guarantee that email will carry correct format of samples along with the samples

        biglist sample below has 2 more lines than newlist sample (between the two samples there are three duplicate records)

        faster to have the smallest doc be the first doc (left hand Ntab tab)

        the clip pauses briefly for a second or two when the status prompt pops up, then the clip processes the 2nd doc

        the results show such that you can select and then choose copy (to windows clipboard) any or all portion of them that you desire. then you can paste as desired.

        Tasks list next

        0. Designed for two adjacent Ntab doc tabs (documents). Of the two, focus the left hand tab first then run the clip

        1. on a line by line basis, goes down thru 1st doc -> find BOL to ^t of each line and append onto accum variable

        2. set accum into a ^p delim array

        3. exit 1st loop, doc_index to 2nd doc, enter 2nd loop

        4. on an "item by item" basis, "work" the ^p delim array, find if each item does exist in the 2nd doc. If an item exists again in the 2nd doc, it gets appended onto the %dups% variable

        5. show the duplicated records which can then select, copy, paste

        --------- clip begins next -----------

        H="Compare 2 Docs"
        ; Last edited:Thursday, 17 May 2001
        ; Alan Cummings
        ^!ClearVariables
        ^!Set %doc_idx%=^$GetDocIndex$
        ^!Jump DOC_START
        :init_loop
        ^!Find "Car Model:" IS
        ^!Jump SELECT_END
        ^!Find "^t"
        ^!Jump SELECT_START
        ^!Select BOL
        ^!Set %record%=^$GetSelection$
        ^!Append %accrue%=^%record%^%NL%
        ^!If ^$GetRow$ >= ^$GetTextLineCount$ skip_2
        ^!Jump +1
        ^!Goto init_loop
        ; ^!Info ^%accrue%
        ; completed init_loop, prep for mid_loop
        ^!SetListDelimiter ^p
        ^!SetArray %initlins%=^%accrue%
        ^!Set %index%=0
        ^!StatusShow -> Auto to 2nd Doc now ->
        ^!Delay 15
        ^!Inc %doc_idx%
        ^!SetDocIndex ^%doc_idx%
        :mid_loop
        ^!Inc %index%
        ^!Find "^%initlins^%index%%" IWS
        ^!IfError skip
        ^!Append %dups%=^%initlins^%index%%^%NL%
        ^!If ^%index% > ^%initlins0% skip
        ^!Goto mid_loop
        ; completed mid_loop, display duplicate entries
        ^!SetWizardTitle _____Duplicate Records_____
        ^!Info [L]Duplicates:^%NL%^%NL%^%dups%
        ;-----<end of clip<<

        Car Model: Toyota Celica Car Specs: ...
        Car Model: Toyota Paseo Car Specs: ...
        Car Model: Toyota Tercel Car Specs: ...
        Car Model: Toyota SR5 Car Specs: ...
        Car Model: Toyota Pickup Car Specs: ...
        Car Model: Starship Enterprise Car Specs: ...
        -----end of newlist-------

        Car Model: Honda Civic Car Specs: ...
        Car Model: Honda Prelude Car Specs: ...
        Car Model: Toyota Tercel Car Specs: ...
        Car Model: Honda Accord Car Specs: ...
        Car Model: Toyota Pickup Car Specs: ...
        Car Model: Chevrolet Camaeo Car Specs: ...
        Car Model: Ford Pickup Car Specs: ...
        Car Model: Starship Enterprise Car Specs: ...
        -----end of biglist-------

        bye,
        Alan.
      • Tietjen, Richard
        ... From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] Sent: Thursday, May 17, 2001 5:36 AM To: ntb-clips@yahoogroups.com Subject: [Clip]
        Message 3 of 5 , May 17, 2001
        • 0 Attachment
          -----Original Message-----
          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com]
          Sent: Thursday, May 17, 2001 5:36 AM
          To: ntb-clips@yahoogroups.com
          Subject: [Clip] Digest Number 376


          There is 1 message in this issue.

          Topics in this digest:

          1. IF EXIST "expression" in TEXT FILE
          From: gp3@...


          ________________________________________________________________________
          Message: 1
          Date: Wed, 16 May 2001 11:48:07 -0000
          From: gp3@...
          Subject: IF EXIST "expression" in TEXT FILE

          Hi, I have a huge problem.
          ________________________________________________________________________

          Why don't you use a DOS port of the Unix/GNU diff utility?
          http://www.gnu.org/software/diffutils/diffutils.html

          If that fails, use a text processing tool like perl or awk.

          With all due respect, Notetab is a text editor with a useful mini-language
          for customizing its interface. Lots of things text processing things are
          hard to do in Notetab but easy in Awk or Perl; things like your problem.






          [Non-text portions of this message have been removed]
        • Manuel
          Hi ¡ I would like surfing with botom back and forwad in a otl document similar to web page. Here it s my idea. When I want to jump to [link] I execute clip
          Message 4 of 5 , May 19, 2001
          • 0 Attachment
            Hi ¡

            I would like surfing with botom back and forwad in a otl document
            similar to web page.

            Here it's my idea.
            When I want to jump to [link] I execute clip forward
            Then I read the item and to finish I execute clip back

            Here it's the clip that i would like tell me what I can change for
            better ok.

            The idea it's jump to a file link and to back the back file and put
            the cursor in the line when I went when I jump to link. When I am in
            the second file I want to close document and back to document one.

            All similar to browser
            It's work ok from links otl to txt, when I go back :-?

            But other question it's the possibilities to show a list of links I
            visited and I can select one to jump them.

            H="FORWAD"
            ;Asign to variables f,t,f
            ;name of document, topic number, line number
            ^!Set %f%=^$GetDocName$
            ^!Set %t%=^$GetTopicIndex$
            ^!Set %fila%=^$GetRow$

            ;Jump to link
            ^!Keyboard Ctrl+H



            H="BACK"
            ^!Toolbar Close Document
            ^!OPEN "^%f%"

            ;^!info ^%fila%
            ^!SetTopicIndex ^%t%

            ^!Jump ^%fila%


            Have a nice day.
            ---
            manuel123@...
            Cursos para ciegos (Courses for blind people)
            Windows,Iexplorer,Outlook,Html,Word,Excel,Access
            http://manuel123.8m.com (en español)
            http://infoman.8m.com (english page)
          • Alan C.
            Hi ¡ Manuel, ... I didn t see anything. But sometimes interuption occurs, at least it does so for me, whereby the variables don t seem to hold and work
            Message 5 of 5 , May 20, 2001
            • 0 Attachment
              Hi ¡ Manuel,

              >Here it's the clip that i would like tell me what I can change for
              >better ok.

              I didn't see anything. But sometimes interuption occurs, at least it does so for me, whereby the variables don't seem to hold and work again after activity that occurred prior to running a 2nd clip which accesses variables set by the first clip.

              You might try adding p_ onto the front of each of your variables (Ntab help | clip language variables)

              Or, Instead of variables, write the values to an ini file then pull them when needed (I still have yet to learn this one its got to be easy though).

              Or, if a teeny bit of disk activity is ok (writes a very small file to disk each time) then write a farclip (to disk) then run the farclip to get back. The following does so. (it got back really well) If desire, you can run the forward clip then go to Ntab's scripts directory and open the mysurf.dat file to see that it is nothing but a clip with three clip commands in it.

              TextToFile line is rather lengthy; also critical in same line there is some needed spaces, needed for the clip commands in the mysurf.dat file. And may be other lines long enough that accrue email line breaks.

              H="FORWAD"
              ^!Set %open%=_~Open
              ^!Set %sti%=_~SetTopicIndex
              ^!Set %jmp%=_~Jump
              ;
              ^!Set %open%=^$StrReplace(_;^;^%open%;False;False)$
              ^!Set %open%=^$StrReplace(~;!;^%open%;False;False)$
              ;
              ^!Set %sti%=^$StrReplace(_;^;^%sti%;False;False)$
              ^!Set %sti%=^$StrReplace(~;!;^%sti%;False;False)$
              ;
              ^!Set %jmp%=^$StrReplace(_;^;^%jmp%;False;False)$
              ^!Set %jmp%=^$StrReplace(~;!;^%jmp%;False;False)$
              ;
              ^!Deletefile ^$GetScriptPath$mysurf.dat
              ^!TextToFile "^$GetScriptPath$mysurf.dat" ;storeit^%NL%^%NL%H="surfnow"^%NL%^%open% "^$GetDocName$"^%NL%^%sti% ^$GetTopicIndex$^%NL%^%jmp% ^$GetRow$
              ;---end of long line
              ; Jump to link
              ^!Keyboard Ctrl+H
              ;----<end of clip<<

              H="BACK"
              ^!Toolbar Close Document
              ^!FarClip "^$GetScriptPath$mysurf.dat:"surfnow""
              ;----<end of clip<<

              Fly hi once in a while. Take caution while doing so. Have fun. Alan.
            Your message has been successfully submitted and would be delivered to recipients shortly.