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

Skip first n lines when reading from a Google Sheet (default 0) #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions python-connectors/googlesheets-sheet/connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@
"mandatory": true,
"defaultValue": "USER_ENTERED",
"visibilityCondition": "model.show_advanced_parameters==true"
},
{
"name": "lines_to_skip",
"label": "Number of lines to skip",
"type": "INT",
"mandatory": true,
"defaultValue": 0,
"visibilityCondition": "model.show_advanced_parameters==true"
}
]
}
3 changes: 2 additions & 1 deletion python-connectors/googlesheets-sheet/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, config):
self.tabs_ids = get_tab_ids(config)
self.result_format = self.config.get("result_format")
self.write_format = self.config.get("write_format")
self.lines_to_skip = self.config.get("lines_to_skip")
self.list_unique_slugs = []
self.add_sheet_name_column = self.config.get("add_sheet_name_column", False)

Expand Down Expand Up @@ -60,7 +61,7 @@ def generate_rows(self, dataset_schema=None, dataset_partitioning=None,
for worksheet in worksheets:
if self.tabs_ids and (worksheet.title not in self.tabs_ids):
continue
rows = worksheet.get_all_values()
rows = worksheet.get_all_values()[self.lines_to_skip:]
try:
columns = rows[0]
except IndexError:
Expand Down