File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,28 @@ def search_term_filter_df(df, text):
363
363
self .search_results_list .hide ()
364
364
365
365
366
+ def handle_search_item_click (self , item ):
367
+ # Extract all relevant text within last parentheses; BUT only need last parentheses, cf. "my country (Belgium) subject X (code)"
368
+ # Assumes the (code) is always contained in last parentheses
369
+ matches = re .findall (r'\(([^)]+)\)' , item .text ())
370
+
371
+ if matches :
372
+ last_match = matches [- 1 ]
373
+
374
+ # Use the code extracted text from the clicked item (this ought to be correct dataset code)
375
+ code = last_match
376
+
377
+ # Use 'code' to load the dataset via eurostat_get
378
+ from larray_eurostat import eurostat_get
379
+ arr = eurostat_get (code , cache_dir = '__array_cache__' )
380
+
381
+ # Add loaded dataset to editor and shell
382
+ editor = self .parent ()
383
+ new_data = editor .data .copy ()
384
+ new_data [code ] = arr
385
+ editor .update_mapping (new_data )
386
+ editor .kernel .shell .user_ns [code ] = arr
387
+
366
388
367
389
def showAdvancedPopup (self ):
368
390
popup = AdvancedPopup (self )
You can’t perform that action at this time.
0 commit comments