[英]Reading a value from csv file dash python
我在像(123.456,789.1234)
这样的 csv 文件中有值 map_geo_location ,如何在 dash 中获取值以将其添加为 python 中属性lan
和lat
geo 分散破折号的值?
list.txt:列表.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)
and then:进而:
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))
OUTPUT:输出:
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']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.