Topic: Search with a string from a diffrent file (1 of 15), Read 79 times
Conf: Search and Replace
From: J P
Date: Wednesday, March 02, 2005 11:42 PM

I have a list of files that I want to find in a very large list of files. Each file name is in it's own row in one file and I have a large list in a second file, how do I search using the file name from the first?

I want to output the file list into a separate .txt file.

 


Topic: Re: Search with a string from a diffrent file (2 of 15), Read 69 times
Conf: Search and Replace
From: Christian Ziemski
Date: Thursday, March 03, 2005 02:40 AM

On Wed, 02 Mar 2005 23:42:00 -0500, you wrote:

>I have a list of files that I want to find in a very large list
>of files.
>Each file name is in it's own row in one file and I have a large
>list in a second file, how do I search using the file name from
>the first?
>
>I want to output the file list into a separate .txt file.

Joshua:

If I understand your problem correctly here a possible way.
It's not tested, so you'll have to do that ;-)


File_with_filenames_to_search
-----------------------------
Filename2
Filename9


MasterFile_with_filenames
-------------------------
Filename1
Filename2
Filename3
Filename4
Filename5
Filename6
Filename7

should give:

Resulting_list_with_found_files
-------------------------------
Filename2





File_Open("File_with_filenames_to_search")
#103=Buf_Num // remember the number of it's buffer

File_Open("Masterfile_with_filenames")
#104=Buf_Num // remember the number of it's buffer


Buf_Switch(#103) // search list
Begin_Of_File
File_Save_As("Resulting_list_with_found_files")

while (! At_EoF) { // loop through the search list
Reg_Copy_Block(103, Cur_Pos, EoL_Pos)// get one line (filename)
Buf_Switch(#104) // switch to masterlist
Search("|@(103)", BEGIN+NOERR) // search the filename here
if (Error_Match) { // if not found here
Buf_Switch(#103) // delete item from search list
Del_Line(1)
} else { // if found:
Buf_Switch(#103) // leave item in search list
Line(1, NOERR) // next item in search list
}
}

File_Save(OK) // save result




Christian

 


Topic: Re: Search with a string from a diffrent file (3 of 15), Read 72 times
Conf: Search and Replace
From: Ian Binnie
Date: Thursday, March 03, 2005 05:48 PM

You don't say exactly what you want to do, but you may find REM-LINES does what you want.

It is well documented, but in brief it searches a file for lines which match in another file, and results in 2 files, with matched & unmatched files.

I use this all the time to compare file lists.

 


Topic: Re: Search with a string from a diffrent file (4 of 15), Read 71 times
Conf: Search and Replace
From: Christian Ziemski
Date: Friday, March 04, 2005 02:20 AM

On Thu, 03 Mar 2005 17:48:00 -0500, Ian Binnie wrote:

>You don't say exactly what you want to do, but you may find REM-LINES
>does what you want.

Ian:
Joshua (JP) has been the person with the question, not me.
Somehow your answer got positioned as reply to my answer.


Anyway: Hey, I didn't know about REM-LINE.VDM.
(Or to be exact: I always thought it means "REMARK-LINE.VDM" and
ignored it.)

It seems to be a really useful macro! Thanks for the hint!

Christian

 


Topic: Re: Search with a string from a diffrent file (5 of 15), Read 67 times
Conf: Search and Replace
From: Ted Green
Date: Friday, March 04, 2005 11:16 AM

At 02:20 AM 3/4/2005, you wrote:
>Anyway: Hey, I didn't know about REM-LINE.VDM.
>(Or to be exact: I always thought it means "REMARK-LINE.VDM" and
>ignored it.)
>It seems to be a really useful macro! Thanks for the hint!

OK, I will rename it in the menu to REMOVE-LINES.

Ted.

 


Topic: Search with a string from a diffrent file (6 of 15), Read 65 times
Conf: Search and Replace
From: J P
Date: Friday, March 04, 2005 11:18 AM

This is my first vedit macro, I'm still in school (CompSci Major)and this is a add on for a project I'm working on.

I wasn't exactly clear on what I was doing, my apologies. I have a list of different file reference numbers, and then a list of files, some are compressed (.zip) others not.

My list file contains:

12345678
32158766
00000001
...

and my file list contains:
blahblah 12345678 blahblahblah
blahblah 55567000 blahblahblah
c:\archive\stuff.zip
blahblah 00000001 blahblahblah
c:\archive\more_stuff.dat
...

I want to get a text file that will output just the file location line. I'm trying to search starting from the line where the file id was found for ":\" and grab the whole line, but I cannot seem to get anything to work correctly.

-Thanks for your help.

 


Topic: Re: Search with a string from a diffrent file (7 of 15), Read 63 times
Conf: Search and Replace
From: Christian Ziemski
Date: Friday, March 04, 2005 11:47 AM

On Fri, 04 Mar 2005 11:18:00 -0500, J P wrote:

>I have a list of different file reference numbers, and then a list
>of files, some are compressed (.zip) others not.
>
>[...]
>
>I want to get a text file that will output just the file
>location line.
>I'm trying to search starting from the line where the file id
>was found for ":\" and grab the whole line,
>but I cannot seem to get anything to work correctly.


I'm still not sure what you want to do...
(English isn't my native language, perhaps it's my fault.)

Can you please post the desired result (the "data") according to your
example given in your last message?

Or even better: Write down your plan in some "pseudo code" (no problem
for a future CompSci Major, right ;-) )

Together we should be able to build a VEDIT macro then.


Christian

 


Topic: Re: Search with a string from a diffrent file (8 of 15), Read 62 times
Conf: Search and Replace
From: J P
Date: Friday, March 04, 2005 12:46 PM

I would like a output file that will just have the file location.

c:\archive\stuff.zip
c:\archive\more_stuff.dat

Some files are not on the list and some are, so a simple search is not possible.

I'm a bit better with c++ so:

int search_count;
int list_count = 1;

Open file_list.txt

While (!EOF File_list.txt)
{
search_count = 1
Do
{
Open Search_File.txt
read line search_count of Search file.txt
if line search_count of Search_file.txt between column
8 and 12 = line list_count of file_list.txt
then
Do
{
search_count++
if column 2 & 3 = ":\"
then output line search_count of Search_file.txt to
output.txt
}
}
while (!EOF search_file.txt)
list_count++
}

 


Topic: Re: Search with a string from a diffrent file (9 of 15), Read 62 times, 1 File Attachment
Conf: Search and Replace
From: Christian Ziemski
Date: Friday, March 04, 2005 02:14 PM

On Fri, 04 Mar 2005 00:46:00 -0500, J P wrote:

>I'm a bit better with c++ so:
>...

Joshua:

I attached a VEDIT macro to this message which is a "translation" of
your C++ code to VDM.

It's not complete, but it should give you a starting point.


Christian

 
JOSHUA.VDM (1KB)

 


Topic: Re: Search with a string from a diffrent file (10 of 15), Read 63 times
Conf: Search and Replace
From: J P
Date: Friday, March 04, 2005 02:24 PM

Thanks, i'll try to get this working.

 


Topic: Re: Search with a string from a diffrent file (12 of 15), Read 60 times
Conf: Search and Replace
From: J P
Date: Monday, March 07, 2005 02:47 AM

I am having trouble getting any output. And I do not understand the syntax "Match("|@(103)") == 0 "

My files are as follows

List.txt:
123456
112233
332211
456875
...

Search.txt:
123456
000444
XC:\directory\File0.dat
111111
XC:\directory\File1.dat
...

And the output I want to have is
Output.txt:
XC:\directory\File0.dat
XC:\directory\File3.dat
...

my current macro is:

File_Open("c:\test\List.txt")
#103=Buf_Num

File_Open("c:\test\Search.txt")
#104=Buf_Num

File_Open("c:\test\Output.txt")
#105=Buf_Num

Buf_Switch(#103) // switch to list.txt

While (! At_EOF) // While Not at EOF of list.txt
{
Reg_Copy_Block(103, Cur_Pos, EoL_Pos) // read current line (without CR/LF)

Buf_Switch(#104) // switch to Search.txt

#90 = 1 //search count

While (! At_EOF) // While not at EOF of Search.txt
{
Goto_Line(#90)
Goto_Col(11)
if (Match("|@(103)") == 0 ) // if matching the text from List.txt
{
#90++
Goto_Col(3)
if (Match(":\") == 0 ) // if column 3 & 4 = ":\"
{
Begin_Of_Line
Reg_Copy(104, 1) // get complete line
Buf_Switch(#105) // switch to output.txt
Reg_Ins(104) // insert line there
Buf_Switch(#104) // switch back to search.txt
}
}
#90++
}
Buf_Switch(#103) // switch back to List.txt
Line(1, NOERR) // next line
}

 


Topic: Re: Search with a string from a diffrent file (13 of 15), Read 67 times
Conf: Search and Replace
From: Christian Ziemski
Date: Monday, March 07, 2005 09:39 AM

On 3/7/2005 2:47:03 AM, J P wrote:
>I am having trouble getting any output.
>And I do not understand the syntax
>"Match("|@(103)") == 0 "

It compares (matches) the contents of text register 103 with the text at the current cursor position. If those two are identical it returns 0.


>my current macro is:
[...]

>Goto_Col(11)
>if (Match("|@(103)") == 0 )
>// if matching the text from List.txt

In your test file the data seems to begin at column 1 and not at column 11! So the text compare (Match) always fails.

Hopefully that will help a bit.


Christian

 


Topic: Re: Search with a string from a diffrent file (14 of 15), Read 61 times
Conf: Search and Replace
From: Christian Ziemski
Date: Monday, March 07, 2005 02:30 PM

Joshua:

Try it with this one.

At least there is an output and I think it makes sense...



File_Open("c:\test\List.txt")
Begin_Of_File // to be safe (if file was already open)
#103=Buf_Num

File_Open("c:\test\Search.txt")
Begin_Of_File // to be safe (if file was already open)
#104=Buf_Num

File_Open("c:\test\Output.txt")
Begin_Of_File // to be safe (if file was already open)
#105=Buf_Num


Buf_Switch(#103) // switch to list.txt

While (! At_EOF) // While Not at EOF of list.txt
{
Reg_Copy_Block(103, Cur_Pos, EoL_Pos) // read curr. line (w/o CR/LF)

Buf_Switch(#104) // switch to Search.txt
Begin_Of_File

While (! At_EOF) // While not at EOF of Search.txt
{
Goto_Col(1) // column with text to find (only in testfile = 1)
if (Match("|@(103)") == 0 ) // if matching the text from List.txt
{
Line(1, NOERR+ERRBREAK) // goto next line
Search("|<X|A:\", NOERR) // search for the next filename
// (with leading X here in testfile)
// See online help for pattern matching codes!

if (!Error_Match) { // if found
Begin_Of_Line
Reg_Copy(104, 1) // get complete line
Buf_Switch(#105) // switch to output.txt
Reg_Ins(104) // insert line there
Buf_Switch(#104) // switch back to search.txt
}
}
Line(1, NOERR)
}
Buf_Switch(#103) // switch back to List.txt
Line(1, NOERR) // next line
}





Christian

 


Topic: Re: Search with a string from a diffrent file (15 of 15), Read 56 times
Conf: Search and Replace
From: J P
Date: Tuesday, March 08, 2005 02:25 AM

Thank you, I got it working with your help.


Thanks
-jp

 


Topic: Search with a string from a diffrent file (11 of 15), Read 57 times
Conf: Search and Replace
From: Ian Binnie
Date: Friday, March 04, 2005 07:25 PM

On 3/4/2005 11:18:57 AM, J P wrote:
>This is my first vedit macro,
>I'm still in school (CompSci
>Major)and this is a add on for
>a project I'm working on.


>I wasn't exactly clear on what
>I was doing, my apologies. I
>have a list of different file
>reference numbers, and then a
>list of files, some are
>compressed (.zip) others
>not.

My list file
>contains:

12345678
32158766
0
>0000001
...

and my file list
>contains:
blahblah 12345678
>blahblahblah
blahblah 55567000
>blahblahblah
c:\archive\stuff.
>zip
blahblah 00000001
>blahblahblah
c:\archive\more_s
>tuff.dat
...

I want to get a
>text file that will output
>just the file location line.
>I'm trying to search starting
>from the line where the file
>id was found for ":\" and grab
>the whole line, but I cannot
>seem to get anything to work
>correctly.

-Thanks for your
>help.


If you just want to do thejob, rather than write your own macro, the solution is already in Vedit

I saved your examples in the following:-

"D:\temp\list_file.txt"
12345678
32158766
00000001

and


"D:\temp\File_list.txt"
blahblah 12345678 blahblahblah
blahblah 55567000 blahblahblah
c:\archive\stuff.zip
blahblah 00000001 blahblahblah
c:\archive\more_stuff.dat


Load the file "D:\temp\File_list.txt" into Vedit

Run rem-line.vdm from Misc/More macros
Enter the name of the list file as "D:\temp\list_file.txt"


Enter the name of the new delta file or accept the default "ediff.txt"

Accept the default filename "match.txt" for "removed" (matching) lines:

Select [Y] to save destination file.

"D:\temp\match.txt" will contain:-

blahblah 12345678 blahblahblah
blahblah 00000001 blahblahblah

"D:\temp\ediff.txt" will contain:-

"D:\temp\list_file.txt"
12345678