Have an exam tomorrow and need to get my program.py file working. I am to parse through a GeoRSS feed https://www.tvfoodmaps.com/MVFN.xml to be specific and obtain these attribute data; "Latitude", "Longitude" , "Title" , "Description" to compile into separate list. After creating these lists, I need to write to create a feature class that would hold these points and data in arcmap. The script is to be run in ArcMap to map out the restaurant locations and contain the information. Right now I'm stuck on getting all the data into tables. The problem is at the get title and description parts because it seems that if I can get the Titles, then it doesn't run Descriptions and vice versa. Any help would be really appreciated! Here's what I have so far;
import os, urllib
#store the pathname to where you want to add text file to
#path = arcpy.GetParameterAsText(0) # pathname to folder
#FullFCOutputPath = arcpy.GetParameterAsText(1)
path = "https://www.tvfoodmaps.com/MVFN.xml"
f = urllib.urlopen(path)
myfile = f.read()
lstFieldNames = [ "Latitude", "Longitude" , "Title" , "Description" ]
lstPoints = myfile.split('<georss:point>')
#print lstPoints[1]
Latitudes = []
Longitudes = []
for Gval in lstPoints:
if Gval.find('</georss:point>') <> -1:
LatPos1 = 0
LatPos2 = Gval.index(' ')
LonPos1 = Gval.index(' ') + 1
LonPos2 = Gval.index('</georss:point>')
Latitudes.append(Gval[LatPos1:LatPos2])
Longitudes.append(Gval[LonPos1:LonPos2])
lstTitles = myfile.split('<item>')
Titles = []
Descriptions = []
#print lstTitles[1]
for Tval in lstTitles:
if Tval.find('<item>') <> -1: #
TlePos1 = Tval.index('<title>') + 7
TlePos2 = Tval.index('</title>')
Title = (Tval[TlePos1:TlePos2])
Title = Title.replace(''',"'")
Titles.append(Title)
elif Tval.find('</description>') <> -1:
DesPos1 = Tval.index('<description>') + 13
DesPos2 = Tval.index('</description>')
Description = (Tval[DesPos1:DesPos2])
Description = Description.replace(''',"'")
Descriptions.append(Description)