How to get values from a nested multi-link table?


table_1_row = <table_1_row>
table_2_rows = table_1_row['link_2'] = List[<table_2_row>]
[r['link_3'] for r in table_2_rows] = List[List[<table_3_row>]]

To flatten this list instead do

values = []
for table_2_row in table_1_row['link_2']:
  for table_3_row in table_2_row['link_3']:
    values.append(table_3_row['value'])

or equivalently with a list comprehension


values = [table_3_row['value']
            for table_2_row in table_1_row['link_2']
              for table_3_row in table_2_row['link_3']
         ]

And to do all table 3 rows :thinking::exploding_head:


values = [table_3_row['value']
          for table_1_row in app_tables.table_1.search()
            for table_2_row in table_1_row['link_2']
              for table_3_row in table_2_row['link_3']
         ]

It feels like inception…

2 Likes