frictionlessdata / tabulator-py

Python library for reading and writing tabular data via streams.
https://frictionlessdata.io
MIT License
235 stars 42 forks source link

XLSX preserve formatting percentage #330

Closed cschloer closed 4 years ago

cschloer commented 4 years ago

Overview

Hi,

There is a bug in the tabulator XLSX parser for the preserve_formatting flag.

Specifically, when cells of type percentage are loaded they are always returned as 0.

The solution is to add

# Return percentage formatted cells as is
if excel_number.endswith('%'):
    return value

To the beginning of the convert_excel_number_format_string function (here https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/parsers/xlsx.py#L334). This will then return 0.5 for a percentage of 50%.

Let me know if you're too busy and I should create a fork myself, just figured it was easier for you since you are more frequently pushing to this repo :)


Please preserve this line to notify @roll (lead of this repository)

cschloer commented 4 years ago

Will update this issue to show 50% instead of 0.5

cschloer commented 4 years ago

I created a PR since that was the easiest way to show.

roll commented 4 years ago

FIXED in #332