【发布时间】:2014-05-24 11:48:06
【问题描述】:
我有包含地点的 geojson 文件。其中 "'parking': 0 " 一直都是。
'type': 'Feature',
'properties': {
...// Other fields
'latitude': -74.0121613846062,
'longitude': 40.7043040747924,
'parking': 0 }
我想从另一个 csv 文件数据集更新它。
-------------------------------------------
latitude + Longitude + Possible_parking
-------------------------------------------
-74.012161 40.804 -1
-1:无法停车
1:可能停车
我想更新 geojson 文件。
data = pd.read_csv("data/_all.csv")
geojson_in = open('data/input.json', 'r')
tracts_geojson = json.load(geojson_in)
geojson_in.close()
# For each record in the geojson file, add location information
for i, r in enumerate(tracts_geojson['features']):
for x in range(len(data.latitude.values)):
if ((r['properties']['latitude']==data["latitude"][x]) and (r['properties']['longitude']== data["longitude"][x])):
r['properties']['parking'] = str(data['Possible_parking'][x])
我使用的脚本的问题是它需要很长时间(现在 +24 小时)。 我不想直接将 csv 文件转换为 json,因为 input.json 包含我在 CSV 文件中找不到的其他信息。
有没有什么pythonic方法可以更快地做到这一点?
【问题讨论】:
-
CSV 文件有多大?
-
CSV 文件大小为:600Mb