Hi everyone,
here is a pastebin link to my question in case I formatted this incorrectly: https://pastebin.com/E1sy9s2B
I have a list of text correspondence that references a “handle_id” number for contact info. The “handle_id” is associated with a phone number or email address which is stored in a list in a separate file. I am trying to replace the “handle_id =” string found in messages.txt with the “id =” string found in contacts.txt The lists look like this:
contacts.txt :
handle_id = 868 id = aust@email.com
handle_id = 920 id = tara@email.ca
handle_id = 921 id = gram@email.ca
handle_id = 922 id = +17786771234
handle_id = 923 id = +12508891234
handle_id = 924 id = +12502171234
handle_id = 925 id = +12508891234
handle_id = 926 id = +12505801234
handle_id = 927 id = +17789701234
handle_id = 970 id = +16137941234
messages.txt :
handle_id = 1541 Sent Fri Mar 23 13:41:02 2018
text = Hi Partner: Called your house & learned you are out at a mtg.
handle_id = 1541 Received Fri Mar 23 16:12:25 2018
text = I got you bud
handle_id = 970 Sent Fri Mar 23 16:13:56 2018
text = Please pickup milk.
What I’m trying to do is search for the “handle_id = XXX” string in messages.txt and replace it with the associated “id =” string found in contacts.txt. To put it another way, I want to search messages.txt for any matches from “column A” in contacts.txt, if a match is found, overwrite it with the “id =” string next to the match in “column B” so that it looks something like this:
MESSAGE LIST:
id = +12507741234 Sent Fri Mar 23 13:41:02 2018
text = Hi Partner: Called your house & learned you are out at a mtg.
id = +12507741234 Received Fri Mar 23 16:12:25 2018
text = I got you bud
id = +16137941234 Sent Fri Mar 23 16:13:56 2018
text = Please pickup milk.
Any help would be much appreciated, thanks!
In reply to Search and replace from one list to another by NicheArchitecture
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |