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
TypeError: Cannot read property 'trim' of undefined #48
Comments
Bitten by this again… the simplest fix is to set but there might be a better way |
Hmm. The expectation is that the fields are empty strings, not undefined. We could replace undefined or null with the empty string, but I think this should be considered a bug with how we parse DSV with missing columns: the missing columns should be represented by empty strings, not undefined. You can see the inconsistency with the roundtrip through DSV formatting here. |
Probably adding a function objectConverter(columns) {
return new Function("d", "return {" + columns.map(function(name, i) {
return JSON.stringify(name) + ": d[" + i + "] || \"\"";
}).join(",") + "}");
} |
Reverses one test, so technically we can say that it breaks the API. However README is silent about this situation, so I don't know. Fixes #48
Reverses one test, so technically we can say that it breaks the API. However README is silent about this situation, so I don't know. Fixes #48
It might happen that CSV files will omit redundant commas, in which case d3.autoType breaks with
TypeError: Cannot read property 'trim' of undefined
This might be a desirable feature, in which case it would be good to trap the error and make it explicit.
However my personal preference would be to have it a bit more fault tolerant and avoid crashing on
d3.autoType({ foo: undefined })
.Especially if d3.autoType is made the default for d3.csv (#43).
The text was updated successfully, but these errors were encountered: