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

#1660: Fix ExcelControl copying of stringified attribute #1661

Merged
Merged
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
17 changes: 17 additions & 0 deletions frictionless/formats/excel/__spec__/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,20 @@
def test_excel_dialect():
with Resource("data/table.xlsx") as resource:
assert isinstance(resource.dialect.get_control("excel"), formats.ExcelControl)

def test_excel_control_to_copy():
"""
Test that the ExcelControl and all its attributes are correctly copied
"""
# Make a control with all values changed from the defaults
control_with_changed_attributes = formats.ExcelControl(
sheet="non-default",
fill_merged_cells=True,
preserve_formatting=True,
adjust_floating_point_error=True,
stringified=True
)

control_copy = control_with_changed_attributes.to_copy()

assert control_copy == control_with_changed_attributes
7 changes: 7 additions & 0 deletions frictionless/formats/excel/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class ExcelControl(Control):
"""
Stringifies all the cell values. Default value
is False.

Note that a table resource schema will still be applied and types coerced to match the schema
(either provided or inferred) _after_ the rows are read as strings.

To return all cells as strings then both set `stringified=True` and specify a
schema that defines all fields to be of type string (see #1659).
"""

# Metadata
Expand All @@ -61,5 +67,6 @@ class ExcelControl(Control):
"fillMergedCells": {"type": "boolean"},
"preserveFormatting": {"type": "boolean"},
"adjustFloatingPointError": {"type": "boolean"},
"stringified": {"type": "boolean"},
},
}
Loading