Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test add pad and ignore hidden sheets #35

Merged
merged 4 commits into from
May 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tap_google_sheets/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,28 @@ def colnum_string(num):
return string


def pad_default_effective_values(headers, first_values):
for i in range(len(headers) - len(first_values)):
first_values.append(OrderedDict())


# Create sheet_metadata_json with columns from sheet
def get_sheet_schema_columns(sheet):
sheet_title = sheet.get('properties', {}).get('title')
sheet_json_schema = OrderedDict()
data = next(iter(sheet.get('data', [])), {})
row_data = data.get('rowData', [])
if row_data == []:
# Empty sheet, SKIP
if row_data == [] or len(row_data) == 1:
# Empty sheet or empty first row, SKIP
LOGGER.info('SKIPPING Empty Sheet: {}'.format(sheet_title))
return None, None

# spreadsheet is an OrderedDict, with orderd sheets and rows in the repsonse
headers = row_data[0].get('values', [])
first_values = row_data[1].get('values', [])
# LOGGER.info('first_values = {}'.format(json.dumps(first_values, indent=2, sort_keys=True)))
# Pad first row values with default if null
if len(first_values) < len(headers):
pad_default_effective_values(headers, first_values)

sheet_json_schema = {
'type': 'object',
Expand Down