Program to add word(s) to each line in another list of words?

Status
Not open for further replies.
To answer the question about what to do with the code on Stackoverflow: the OP there is using vim which is a text editor primarily on *nix platforms but also available in some form on windows. I wouldn't recommend that path for you, this is an easy task in notepad++.

I've just tested the provided sample data and the only regex I needed was
Find what: County.*
Replace with: County

To get the "cartesian product" of the two lists eg.

list 1
Accomack County
Ada County
Adair County
Adams County
Addison County
Aiken County
Aitkin County

list 2
widgets
find widgets
search widgets
lookup widgets
widgets lookup
widget search

You can use a spreadsheet application (I'm using Gnumeric)
1) Paste one list into a column (start in cell A2)
2) Use paste special -> transpose to paste the other list as a row (start in cell B1)
3) You now effectively have a matrix, in cell B2 enter =concatenate($A2," ",B$1) into the formula bar
4) The result of this should be "Accomack County widgets"
5) Drag down to autocomplete the first column
6) Highlight the contents of the first column and drag sideways to autocomplete the matrix
7) Highlight the contents of the matrix and paste this into notepad++
8) Use notepad++ find and replace in extended mode
Find what: \t
Replace with: \n

End result:
Accomack County widgets
Accomack County find widgets
Accomack County search widgets
Accomack County lookup widgets
Accomack County widgets lookup
Accomack County widget search
Ada County widgets
Ada County find widgets
Ada County search widgets
Ada County lookup widgets
Ada County widgets lookup
Ada County widget search
Adair County widgets
Adair County find widgets
Adair County search widgets
Adair County lookup widgets
Adair County widgets lookup
Adair County widget search
Adams County widgets
Adams County find widgets
Adams County search widgets
Adams County lookup widgets
Adams County widgets lookup
Adams County widget search
Addison County widgets
Addison County find widgets
Addison County search widgets
Addison County lookup widgets
Addison County widgets lookup
Addison County widget search
Aiken County widgets
Aiken County find widgets
Aiken County search widgets
Aiken County lookup widgets
Aiken County widgets lookup
Aiken County widget search
Aitkin County widgets
Aitkin County find widgets
Aitkin County search widgets
Aitkin County lookup widgets
Aitkin County widgets lookup
Aitkin County widget search

I appreciate the help... don't have time to mess with it tonight but will try that out tomorrow and report back!
 
I've been messing with gnumeric and trying to follow the instructions you provided for the past 30 minutes, but just can't get this to work. I can paste the first list into A2 but when I try to paste the 2nd list into B1 I see the option for "paste special" but it won't allow me to click it. I tried a few things and gave up.

However, I figured out a way to strip everything after county. Using find/replace, I went through my list and searched for everything I wanted gone, one thing at a time. I replaced , : ; with space, and did the same thing for each state and each states abbreviation. It took maybe 25 minutes. I should have just done this all along, instead of messing with these complicated regex things.

Now I have my list of each county, just "example county" with nothing else before or after. Now I can easily replace "county" with "county keyword".

Thanks again for the help.
 
I've been messing with gnumeric and trying to follow the instructions you provided for the past 30 minutes, but just can't get this to work. I can paste the first list into A2 but when I try to paste the 2nd list into B1 I see the option for "paste special" but it won't allow me to click it. I tried a few things and gave up.

However, I figured out a way to strip everything after county. Using find/replace, I went through my list and searched for everything I wanted gone, one thing at a time. I replaced , : ; with space, and did the same thing for each state and each states abbreviation. It took maybe 25 minutes. I should have just done this all along, instead of messing with these complicated regex things.

Now I have my list of each county, just "example county" with nothing else before or after. Now I can easily replace "county" with "county keyword".

Thanks again for the help.

I did also mention how to do the replace in notepad++ but if you've go it sorted now that's cool.

If you can't do a paste special straight away do a normal paste further on down the sheet, re-copy it from there and then try the paste special again.
 
Status
Not open for further replies.
Back
Top Bottom