Re: two files...
Re: two files...
- Subject: Re: two files...
- From: Walter Ian Kaye <email@hidden>
- Date: Wed, 30 Jun 2004 15:57:50 -0700
At 03:57p -0600 06/30/2004, Martha Espinosa didst inscribe upon an
electronic papyrus:
Hi All,
I have two .txt files. One containing items separated by commas
(comma.txt) and the other with several lines of information
other.txt).
example:
comma.txt file
item 1, item 2, mac/item3, item 4
item 1, item 2, hello, item 4
item 1, item 2, world, item 4
item 1, item 2, mac/mail,,
other.txt
mac/help
mac/mail
mac/item 3
mac/item 0
What I want to do is check the comma.txt file, specifically item 3
and verify it (item 3) exists in the comma.txt file.
You mean in the other.txt file, ya?
If it exists I want to add a "YES" to the front or back of that
line... Any help would be appreciated...
set modifiedCommas to false
set commaParas to every paragraph of (read file "comma.txt")
set otherText to return & (read file "other.txt")
repeat with i from 1 to count commaParas
set tids to applescript's text item delimiters
set applescript's text item delimiters to ","
set item3 to text item 3 of item i of commaParas
set applescript's text item delimiters to tids
if item3 starts with space then set item3 to text 2 thru -1 of item3
if otherText contains (return & item3) then
set item i of commaParas to (item i of commaParas) & ", YES"
set modifiedCommas to true
end if
end repeat
if modifiedCommas then
set fref to (open for access file "comma.txt" with write permission)
set eof fref 0
repeat with p in commaParas
write (p & return) to fref
end repeat
close access fref
end if
NOTE: This is off the top of my head, untested. I may have the syntax
wrong, so please verify/test before using on your original files.
NOTE2: Please do NOT cc me.
-W
o/` deedly deet de dee, two files, deedly deet de dee, two files o/`
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: | |
| >two files... (From: Martha Espinosa <email@hidden>) |