Comments (4)
@zelima
I'm not sure which Python library will take care of inferring the types instead of datahub-client. Where is tableschema-py
's infer
being used in this flow?
If I understand correctly, there's a mismatch between tableschema-js
(which infers some values) and tabulator
(which reads these values with different types). One of these needs to be patched to resolve the issue. Which one exactly needs to be discussed with the frictionless data team - I suggest we open matching issues in the FD repos (for tabulator and tableschema-js) and also start a discussion in the gitter channel.
from assembler.
I'm not sure which Python library will take care of inferring the types instead of datahub-client. Where is tableschema-py's infer being used in this flow?
Nowhere, filed types are forced to be strings. Just thought we could use infer method there, instead of forcing them to be strings.
If I understand correctly, there's a mismatch between tableschema-js (which infers some values) and tabulator
Yes, correct
Which one exactly needs to be discussed with the frictionless data team
I think tablaeschema-js
is working fine in this case, as the types are guessed correctly. I've already opened issue for tabulator here frictionlessdata/tabulator-py#230
from assembler.
Ok so diving deeply into this I've got the following:
Excel treats all numbers as floats. In general, it doesn't care whether your_number % 1 == 0.0 is true or not.
https://stackoverflow.com/a/8826770/6056362
Also, similar problem with openpyxl used by tabulator to parse .xlsx
data
iter_worksheet casts all numeric values as floats.
https://bitbucket.org/openpyxl/openpyxl/issues/131/incorect-reading-integer-in-use_iterators#comment-10399143
Meaning that any number coming from Excel is float
and python parses it as float
, So when stream_remote_resources
complains can't cast value "1.0" for type "integer"
it actually complains correctly.
On the other hand we have XLSX
library from NPM used in CLI to infer a schema for later use. XLSX
library treats number got from excel as JS number (Number(n)
) https://www.npmjs.com/package/xlsx#data-types
Playing around a bit with JS number I've got the following:
let a = Number(1)
let b = Number(1.0)
console.log('Number(1)='+a, '|', 'Number(1.0)='+b)
>>> Number(1)=1 | Number(1.0)=1
console.log(a === b)
>>> true
console.log(a == b)
>>> true
In any case Number(n)
returns "number". Meaning when data.js reads Excel workbook used in datahub-client it gets list of JS numbers. That list of rows (and not path to the file or file buffer) is later used to infer schema by tableschema-js, Leaving us with type: number
if there is not at least one actual float Eg 1.1
So Think if even the excel file would like this
one,two,three
1.0,2.0,3.0
4.0,5.0,6.0
...
We would infer the same exact schema. (Not sure how CSV parser works when it detects correctly)
As a solution, I suggest forcing type integer
to number
if data is xls(x) somewhere here https://github.com/datahq/datahub-client/blob/master/lib/utils/datahub.js#L429
from assembler.
FIXED in frictionlessdata/tabulator-py@9675ead
from assembler.
Related Issues (20)
- Rows are resorted in strange way in some cases HOT 2
- Unable to run tests
- BBTest for private dataset HOT 1
- Boot up specstore service for Black Box tests HOT 1
- New pipeline with goodtables validation HOT 1
- Small improvements for assembler and derived resources HOT 1
- Data Validation pipeline always returns valid report HOT 1
- BB tests for specstore HOT 1
- Datapackage contains Invalid zipped file with 'csv' extension, when there is zipped source. HOT 1
- report for dataset may be overwritten by report for another dataset
- datapackage.json in zip file differs from version on github or pkgstore.datahub.io HOT 1
- Duplicated views HOT 1
- Fix the build HOT 1
- Can not process fields with yearmonth and geopoint HOT 1
- Include hash for derived/report
- Fix failing tests due to changes in specstore HOT 1
- Processor for extracting README for zip
- Processor to update metadata for source HOT 1
- Tests for Purge
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from assembler.