If your text file contains only this structure you have stated in question, you should be able to use ast.literal_eval to parse the data:
txt = '''
"city1" : [[1.1,1.2],[2.1,2.2],[3.1,3.2]],
"city2" : [[5.0,0.2],[4.1,3.2],[7.1,8.2]],
'''
template = '''<state name = '{city}'>
<point lat='{vals[0][0]}', lng='{vals[0][1]}' />
<point lat='{vals[1][0]}', lng='{vals[1][1]}' />
</state>'''
from ast import literal_eval
data = literal_eval('{' + txt + '}')
print(data)
for k, v in data.items():
print(template.format(city=k, vals=v))
Prints:
<state name = 'city1'>
<point lat='1.1', lng='1.2' />
<point lat='2.1', lng='2.2' />
</state>
<state name = 'city2'>
<point lat='5.0', lng='0.2' />
<point lat='4.1', lng='3.2' />
</state>
With files I/O:
template = '''<state name = '{city}'>
<point lat='{vals[0][0]}', lng='{vals[0][1]}' />
<point lat='{vals[1][0]}', lng='{vals[1][1]}' />
</state>'''
from ast import literal_eval
with open('sample.txt', 'r') as f_in, open('sample.out', 'w') as f_out:
data = literal_eval('{' + f_in.read() + '}')
for k, v in data.items():
print(template.format(city=k, vals=v), file=f_out)
EDIT: This example will print all the points to the file:
from ast import literal_eval
with open('sample.txt', 'r') as f_in, open('sample.out', 'w') as f_out:
data = literal_eval('{' + f_in.read() + '}')
for k, v in data.items():
print("<state name = '{city}'>".format(city=k), file=f_out)
for point in v:
print("\t<point lat='{point[0]}', lng='{point[1]}' />".format(point=point), file=f_out)
print('</state>', file=f_out)
The file sample.out will look like:
<state name = 'city1'>
<point lat='1.1', lng='1.2' />
<point lat='2.1', lng='2.2' />
<point lat='3.1', lng='3.2' />
</state>
<state name = 'city2'>
<point lat='5.0', lng='0.2' />
<point lat='4.1', lng='3.2' />
<point lat='7.1', lng='8.2' />
</state>