从 csv 文件破折号中读取值 python

Reading a value from csv file dash python

我在像 (123.456,789.1234) 这样的 csv 文件中有值 map_geo_location ,如何获取破折号中的值以将其添加为属性 lan 和 [=13= 的值] python?

中的地理分散破折号

list.txt:

(123.456,789.1234)
(763.426,659.9834)
(873.566,789.6734)
(773.766,239.234)
(343.776,889.1344)
(873.766,679.1344)

然后:

logFile = "list.txt"
with open(logFile) as f:
    content = f.readlines()

# you may also want to remove empty lines
content = [l.strip() for l in content if l.strip()]

lat = []
long = []

for line in content:
    lat.append(line.rpartition(',')[2].strip(")"))
    long.append(line.rpartition(',')[0].strip("("))


print("Latitude List: {}".format(lat))
print("Longitude List: {}".format(long))

输出:

Latitude List: ['789.1234', '659.9834', '789.6734', '239.234', '889.1344', '679.1344']
Longitude List: ['123.456', '763.426', '873.566', '773.766', '343.776', '873.766']