Specifying Column Order when Exporting CSV

Randy AufDerHeide shared this question 20 months ago

When exporting data as csv, is it possible to specify the column order?

It would make our import/exports into Google Sheets a lot easier.

Replies (2)


There is a work-around solution. NoSQLBooster can export query results. You can add field selection(.project) and sorting methods(.sort) to the query. You can also use the one-click projecting and one-click sorting operation to generate related query code. Then export the query to a CSV file.

BTW, you can export the dataset to excel and then use excel for field selection and sorting.


For example:

    .projection({  //select your columns
        name: 1,
        loves: 1,
        weight: 1,
        gender: 1
    .sort({ //sorting
        weight: -1,
        gender: -1


Thank you for the feedback. I don't think this addresses my concern but it may be because I wasn't clear.

When I export data, I need the fields/columns to be in a specific "position".

For example, when I export, I may want:

Field 1: Weight

Field 2: Gender

Field 3: DOB

Field 4: Name

and just to be clear, lets say I want another saved query to have the columns export like this:

Field 1: DOB

Field 2: Weight

Field 3: Gender

Field 4: Name

** I know some people might say you should do this in another app but if its possible to do it when I export the data, it makes things a lot easier.

Is this possible?


You can adjust the order of field exports through the projection method, and you can save the query or save it as a read-only view for later use.

            Dob: 1,
            Weight: 1,
            Gender: 1,
            Name: 1
      // .saveAsView("query_view")

Leave a Comment
Attach a file