Re: old to new
From: Hal Rosser (hmrosser_at_bellsouth.net)
Date: 12/27/04
- Previous message: Hal Rosser: "Re: can't get field.value"
- In reply to: Steven Been: "old to new"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 26 Dec 2004 23:21:13 -0500
"Steven Been" <stevenb@netvision.net.il> wrote in message
news:cqi4gq$in7$1@news2.netvision.net.il...
>
> Hi all ,
> Tried to do it on my own but have given up!!
> I have 2 very large files (5mega) see small attachments.
> I want to search thru file 45after.txt for a line which starts with
> <UGOCC_PARTNAME> if
> the line above "this found line" starts with <UGOCC_JTFILE> continue
> search -if the
> above line does not contain <UGOCC_JTFILE> then then I want to search
file
> "45before.txt"
> for the exact same line from beginning to end and if a match is found and
> if line
> directly above match contains <UGOCC_JTFILE> then I want to copy and
insert
> the whole
> <UGOCC_JTFILE> line above the line I used as a search in file
"45after.txt".
> Multiple
> occurances in both file need to be checked!!
> To put it in a nutshell line# 3 of file 45before.txt should be inserted
in
> file
> 45after.txt before line# 4.
> line# 11 of file 45before.txt should be inserted in file 45after.txt
before
> line# 11
> line # 27 in 45after.txt shall not be changed!!!!
> Hope I have made myself clear.
> Smbs
I would read the file 'subject to change' into memory as an array of
strings.
then
use a loop to compare each string to the value you're searching for.
If you find it store the array position in a variable you can use later.
inside that loop, you open and read the other file until end of file or
until you find the other string.
when you find it, call another sub or function to resize the array and
insert the line as a new element in the proper place.
After both loops end, open the file and overwrite it with the strings in
your array.
***an easier way may be to read the entire file into a single string
variable
use the "Instr" function to see if the value is there.
then use the "Replace" function to replace one 'phrase' with two 'phrases'
-- Couldn't help but notice you're 'assuming' the xml element will be
found at the beginning of a line. But if I recall, its not required that xml
elements begin at the beginning of a line. -- isn't the newline character
optional ??
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.818 / Virus Database: 556 - Release Date: 12/17/2004
- Previous message: Hal Rosser: "Re: can't get field.value"
- In reply to: Steven Been: "old to new"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|