Coder Social home page Coder Social logo

Comments (15)

kaue avatar kaue commented on September 6, 2024

@sanderheilbron Currently only using the option
orderHeaders - Boolean The most used columns are shown first. (defaults to false).

from jsonexport.

sanderheilbron avatar sanderheilbron commented on September 6, 2024

Thanks @kauegimenes, but that does not always result in a legible document, and requires switching columns inside Excel, Numbers or Google Sheets.

from jsonexport.

kaue avatar kaue commented on September 6, 2024

@sanderheilbron This would work for you?

var jsonexport = require('jsonexport');

var contacts = [{
    name: 'Bob',
    lastname: 'Smith',
    address: {
       number: 1 
    }
},{
    name: 'James',
    lastname: 'David'
},{
    name: 'Robert',
    lastname: 'Miller'
},{
    name: 'David',
    lastname: 'Martin'
}];

jsonexport(contacts, {
   headers: ['lastname', 'name', 'address.number'] 
},function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});

from jsonexport.

kaue avatar kaue commented on September 6, 2024

@sanderheilbron In v2.0.0 you can use the headers option to change the order.

from jsonexport.

sanderheilbron avatar sanderheilbron commented on September 6, 2024

Hi @kauegimenes I've used your code example, and nine times out of ten the order of headers is correct. I noticed that the order could change sometimes because of the data set, but this is no issue for me.

Before using this header option it was possible to rename the headers. I would like to know if there is still a possibilty to change the header name?

Thanks for your effort and the v2.0.0 update!

from jsonexport.

sanderheilbron avatar sanderheilbron commented on September 6, 2024

Hi @kauegimenes v2.0.2 supports my code to rename headers.

from jsonexport.

kaue avatar kaue commented on September 6, 2024

@sanderheilbron Currently there is no way to rename headers, i will see if i can add this option later.
About the incorrect order, can you help me reproduce this bug?

from jsonexport.

kaue avatar kaue commented on September 6, 2024

@sanderheilbron v2.0.1 and v2.0.2 was only to get better performace.

from jsonexport.

sanderheilbron avatar sanderheilbron commented on September 6, 2024

@kauegimenes v2.0.2 was the latest version when I installed the module. Just wanted to inform you about it.

Yes, I will check which data set results in a different order of headers.

from jsonexport.

kaue avatar kaue commented on September 6, 2024

@sanderheilbron What you think about this implementation to rename headers #25 ?

from jsonexport.

sanderheilbron avatar sanderheilbron commented on September 6, 2024

@kauegimenes Looks awesome! A lot cleaner than my current solution.

from jsonexport.

kaue avatar kaue commented on September 6, 2024

@sanderheilbron You should be able to use it with v2.0.4

from jsonexport.

sanderheilbron avatar sanderheilbron commented on September 6, 2024

@kauegimenes I've checked all my test data sets, but none of those sets result in a incorrect order of headers. Consider this issue as resolved.

from jsonexport.

kaue avatar kaue commented on September 6, 2024

@sanderheilbron Thanks for the update.

Feel free to create another issue if you think about another useful feature!

from jsonexport.

sanderheilbron avatar sanderheilbron commented on September 6, 2024

@kauegimenes I've tested the rename header option and it works like a charm. Thanks!!!

from jsonexport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.