Skip to content

Commit

Permalink
fix(python): Improve error handling of ParameterCollisionError in `…
Browse files Browse the repository at this point in the history
…read_excel` (#16100)
  • Loading branch information
wsyxbcl authored May 7, 2024
1 parent 2970c57 commit acb601d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions py-polars/polars/io/spreadsheet/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,17 @@ def _read_spreadsheet(

# normalise some top-level parameters to 'read_options' entries
if engine == "calamine":
if "schema_sample_rows" in read_options:
if ("schema_sample_rows" in read_options) and (
infer_schema_length != N_INFER_DEFAULT
):
msg = 'cannot specify both `infer_schema_length` and `read_options["schema_sample_rows"]`'
raise ParameterCollisionError(msg)
read_options["schema_sample_rows"] = infer_schema_length

elif engine == "xlsx2csv":
if "infer_schema_length" in read_options:
if ("infer_schema_length" in read_options) and (
infer_schema_length != N_INFER_DEFAULT
):
msg = 'cannot specify both `infer_schema_length` and `read_options["infer_schema_length"]`'
raise ParameterCollisionError(msg)
read_options["infer_schema_length"] = infer_schema_length
Expand Down

0 comments on commit acb601d

Please sign in to comment.