-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
'columns' unparse config not working when first object doesn't have all properties #918
Comments
I guess the problem is that the columns array is modified on the first colum when it should not be. |
Thanks for the quick response. I will try to make the PR. As this would be my first contribution to Papaparse, do you @pokoli have some pointers for me where I would have to look for a solution/implement the tests and the code? |
@TheSlimvReal That will be great.
|
After going through the tests cases I found this one: {
description: "Column option used to manually specify keys",
notes: "...",
input: [{a: 1, b: '2'}, {}, {a: 3, d: 'd', c: 4,}],
config: {columns: ['a', 'b', 'c']},
expected: 'a,b,c\r\n1,2,\r\n\r\n3,,4'
}, Which made me realize that with ...
const result = Papa.unparse(
rows, // <-- pass the data object directly instead of { data: rows }
{
header: true,
columns: columns,
}
);
... My above example works. Therefore my question @pokoli: Is it a bug that it does not work when passing an object instead of an array or is this behavior intended? |
anyway I created a PR that resolves the issue #919 |
Generally, I am wondering whether the options |
When using the
columns
unparse config option together with a data array where the first object does not have all properties that are listed in thecolumns
array, then not all columns of thecolumns
array are used even if later objects have these values.E.g.
The
result
isinstead of the expected
The text was updated successfully, but these errors were encountered: