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.

json2csv writes all data in single columns

See original GitHub issue

I am using below method, to convert json data into CSV, problem I am facing is it writes all columns in single column. This causes formatting issues. I want to write each column in separate excel column.

csv = json2csv(jsonData, { fields});

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
nakshaycommented, Aug 27, 2019

I found the issue, the encoding for the excel should be “Big endian”, in notepad ++ when I change encoding to UCS-2 LE BOM, it works properly.

1reaction
juanjoDiazcommented, Aug 26, 2019

Could just give me some data to see what does excelJson looks like? Is it an array of arrays? An array of objects? Something else?

Also two notes:

  • The right way to pass the fields option is as part of an object. So csv = json2csv(excelJson, { fields });
  • Also, using the keys from the first object is the default behaviour so you can skip that and just do csv = json2csv(excelJson);
Read more comments on GitHub >

github_iconTop Results From Across the Web

when convert to json2csv all headers and datas coming same ...
I use the json2csv module to convert the data I have to the csv extension and send it by mail, but all the...
Read more >
json2csv - Mirco Zeiss
json2csv. Converts json into csv with column titles and proper line endings. Can be used as a module and from the command line....
Read more >
json2csv - npm
json2csv. Converts json into csv with column titles and proper line endings. Can be used as a module and from the command line....
Read more >
Convert multiple JSON files to CSV Python - GeeksforGeeks
Example 1: If all columns match. In this example, we will load two json files, concatenate one to another ... Convert JSON to...
Read more >
Pandas Write DataFrame to CSV - Spark by {Examples}
DataFrame.to_csv() method you can write/save/export a pandas DataFrame to CSV File ... Column Names While Writing; Handling Missing Values (None/NaN); Write ...
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