nastasiasnk commited on
Commit
7da3f75
1 Parent(s): c90f3ae

Update imports_utils.py

Browse files
Files changed (1) hide show
  1. imports_utils.py +12 -2
imports_utils.py CHANGED
@@ -175,6 +175,8 @@ def fetchSubdomainMapper (livabilityAttributePages):
175
 
176
 
177
  def fetchDistanceMatrices (stream_distance_matrices):
 
 
178
 
179
  # navigate to list with speckle objects of interest
180
  distance_matrices = {}
@@ -185,9 +187,17 @@ def fetchDistanceMatrices (stream_distance_matrices):
185
  distance_matrix_dict = json.loads(distM[kk])
186
  origin_ids = distance_matrix_dict["origin_uuid"]
187
  destination_ids = distance_matrix_dict["destination_uuid"]
188
- distance_matrix = distance_matrix_dict["matrix"]
189
  # Convert the distance matrix to a DataFrame
190
- df_distances = pd.DataFrame(distance_matrix, index=origin_ids, columns=destination_ids)
 
 
 
 
 
 
 
 
191
 
192
  # i want to add the index & colum names to dist_m_csv
193
  #distance_matrices[kk] = dist_m_csv[kk]
 
175
 
176
 
177
  def fetchDistanceMatrices (stream_distance_matrices):
178
+
179
+ nested_list = []
180
 
181
  # navigate to list with speckle objects of interest
182
  distance_matrices = {}
 
187
  distance_matrix_dict = json.loads(distM[kk])
188
  origin_ids = distance_matrix_dict["origin_uuid"]
189
  destination_ids = distance_matrix_dict["destination_uuid"]
190
+ # distance_matrix = distance_matrix_dict["matrix"]
191
  # Convert the distance matrix to a DataFrame
192
+ chunks = distance_matrix_dict["chunks"]
193
+
194
+ # Iterate through 'row_data' to extract the rows
195
+ for chunk in chunks:
196
+ for row_obj in chunk['@rows']:
197
+ row = row_obj['@row']
198
+ nested_list.append(row)
199
+
200
+ df_distances = pd.DataFrame(nested_list, index=origin_ids, columns=destination_ids)
201
 
202
  # i want to add the index & colum names to dist_m_csv
203
  #distance_matrices[kk] = dist_m_csv[kk]