I have a list of cities in a text file called city.txt. Each city on its own line such as
city1
city2
city3
city4
I then have another file that will have city names dispersed throughout the file. This file is a press release, so it isn't in any specific format. What I would like to do, is search the press release for any cities that match the cities listed in the city.txt file. I would like to have it output in the format
'city1','city2','city3'
I would also like to avoid any duplicates. Is this possible? I have something similar for MS Word, and excel, but would like o have this on unix and don't know where to begin.
Thanks
It might help, so I figure I will go ahead and post the word macro.
Dodge20
city1
city2
city3
city4
I then have another file that will have city names dispersed throughout the file. This file is a press release, so it isn't in any specific format. What I would like to do, is search the press release for any cities that match the cities listed in the city.txt file. I would like to have it output in the format
'city1','city2','city3'
I would also like to avoid any duplicates. Is this possible? I have something similar for MS Word, and excel, but would like o have this on unix and don't know where to begin.
Thanks
It might help, so I figure I will go ahead and post the word macro.
Code:
Sub findcities()
Dim a As New Collection, xlApp As Object, xlWkb As Object, str1
Dim WorkBookName, SheetName, ColumnNumber
WorkBookName = "C:\cities.xls"
SheetName = "Sheet1"
ColumnNumber = 1
Set xlApp = CreateObject("Excel.Application")
Set xlWkb = xlApp.Workbooks.Open(WorkBookName)
For i = 1 To xlWkb.sheets(SheetName).Range("A65536").End(&HFFFFEFBE).Row
str1 = Trim(xlWkb.sheets(SheetName).Cells(i, ColumnNumber).Value)
If ActiveDocument.Content.Find.Execute(FindText:=str1, MatchWholeWord:=True) Then
On Error Resume Next: a.Add str1, CStr(str1): On Error GoTo 0
End If
Next i
xlWkb.Close 0: xlApp.Quit: str1 = ""
Open "C:\Cities.txt" For Output As #1
For i = 1 To a.Count
str1 = str1 & "'" & a.Item(i) & "',"
Next i
Print #1, Left(str1, Len(str1) - 1)
Close #1
Shell "notepad.exe c:\cities.txt", vbMaximizedFocus
End Sub
Dodge20