Skip to content

Commit d3b5b63

Browse files
update import airtable
1 parent a7cea81 commit d3b5b63

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

seatable_api/convert_airtable.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ def parse_multiple_select(self, value):
139139
def parse_text(self, value):
140140
if isinstance(value, dict) and 'text' in value:
141141
return value['text'] # barcode
142+
if isinstance(value, dict) and 'name' in value:
143+
return value['name'] # collaborator
144+
if isinstance(value, list) and value and \
145+
isinstance(value[0], dict) and 'name' in value[0]:
146+
collaborators = []
147+
for item in value:
148+
collaborators.append(item['name'])
149+
return ', '.join(collaborators) # collaborators
142150
value = str(value)
143151
return value
144152

@@ -295,23 +303,7 @@ def get_column_data(self, link_map, table_name, column_name, column_type, values
295303
select_list.append(item)
296304
column_data = {'options': self.get_select_options(select_list)}
297305
elif column_type == ColumnTypes.COLLABORATOR:
298-
if isinstance(values[0], dict):
299-
column_type = ColumnTypes.SINGLE_SELECT
300-
select_list = []
301-
for value in values:
302-
name = value['name']
303-
if name not in select_list:
304-
select_list.append(name)
305-
column_data = {'options': self.get_select_options(select_list)}
306-
elif isinstance(values[0], list):
307-
column_type = ColumnTypes.MULTIPLE_SELECT
308-
select_list = []
309-
for value in values:
310-
for item in value:
311-
name = item['name']
312-
if name not in select_list:
313-
select_list.append(name)
314-
column_data = {'options': self.get_select_options(select_list)}
306+
column_type = ColumnTypes.TEXT
315307
except Exception as e:
316308
print('[Warning] get', column_type.value, 'column data error:', e)
317309
return column_type, column_data
@@ -372,8 +364,12 @@ def get_column_type(self, values):
372364
column_type = ColumnTypes.BARCODE
373365
#
374366
type_list.append(column_type)
375-
column_type = max(
376-
type_list, key=type_list.count) if type_list else ColumnTypes.TEXT
367+
if not type_list:
368+
column_type = ColumnTypes.TEXT
369+
elif ColumnTypes.LONG_TEXT in type_list: # longtext
370+
column_type = ColumnTypes.LONG_TEXT
371+
else:
372+
column_type = max(type_list, key=type_list.count)
377373
except Exception as e:
378374
print('[Warning] get column type error:', e)
379375
return column_type

0 commit comments

Comments
 (0)