question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'columns' unparse config not working when first object doesn't have all properties

See original GitHub issue

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 the columns array, then not all columns of the columns array are used even if later objects have these values.

E.g.

const columns= ["First", "Second", "Third"];
const rows= [
  { First: "1-1"},
  {
    First: "2-1",
    Second: "2-2",
    "Third": "2-3",
  },
];
const result = Papa.unparse(
  { data: rows},
  {
    header: true,
    columns: columns,
  }
);
console.log(result)

The result is

First
1-1
2-1

instead of the expected

First,Second,Third
1-1,,
2-1,2-2,2-3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pokolicommented, Feb 24, 2022

I guess the problem is that the columns array is modified on the first colum when it should not be. Could you please upload a PR to fix it which includes a minimum test case (your example sounds like a good solution)

0reactions
TheSlimvRealcommented, Feb 24, 2022

Generally, I am wondering whether the options columns and fields are not the same thing and columns could therefore be removed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mapping an index over more than one column across entity ...
I need to generate migration for my entity "Contact" has the "Complex Type -> Address". So far so good! However, in the "Contact"...
Read more >
Generated Values - EF Core - Microsoft Learn
How to configure value generation for properties when using Entity Framework Core.
Read more >
How to update a key of object with value in json column with ...
What you're passing into update is a JS object (docs). You cannot have multiple keys with identical values (docs). You'll have to do...
Read more >
Entities - typeorm - GitBook
Basic entities consist of columns and relations. Each entity MUST have a primary column (or ObjectId column if are using MongoDB).
Read more >
Content Configuration - Tailwind CSS
Configuring source paths. Tailwind CSS works by scanning all of your HTML, JavaScript components, and any other template files for class names, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found