gristlabs_grist-core/sandbox/grist/imports/register.py
Alex Hall 6c90de4d62 (core) Switch excel import parsing from messytables+xlrd to openpyxl, and ignore empty rows
Summary:
Use openpyxl instead of messytables (which used xlrd internally) in import_xls.py.

Skip empty rows since excel files can easily contain huge numbers of them.

Drop support for xls files (which openpyxl doesn't support) in favour of the newer xlsx format.

Fix some details relating to python virtualenvs and dependencies, as Jenkins was failing to find new Python dependencies.

Test Plan: Mostly relying on existing tests. Updated various tests which referred to xls files instead of xlsx. Added a Python test for skipping empty rows.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3406
2022-05-12 14:43:21 +02:00

20 lines
663 B
Python

def register_import_parsers(sandbox):
def parse_csv(file_source, options):
from imports.import_csv import parse_file_source
return parse_file_source(file_source, options)
sandbox.register("csv_parser.parseFile", parse_csv)
def parse_excel(file_source, parse_options):
# pylint: disable=unused-argument
from imports.import_xls import import_file
return import_file(file_source)
sandbox.register("xls_parser.parseFile", parse_excel)
def parse_json(file_source, parse_options):
from imports.import_json import parse_file
return parse_file(file_source, parse_options)
sandbox.register("json_parser.parseFile", parse_json)