Skip to content

Made a tool to rename columns, want to integrate it #814

Closed
@culebron

Description

@culebron

Example: I often have to export data from MongoDB where columns are extracted from an hierarchy, and have weird names.

mongoexport -d my_db -c my_collection --csv
       -f id,geopos.coordinates.0,geopos.coordinates.1,address > data.csv

There's no direct way in csvkit to rename those columns, only remove them completely or write a pipe, something like echo "column1,column2" > my_file.csv && head +2 >> my_file.csv.

I suggest to make a tool or an option to rename columns.

  • Option 1: a parameter to csvcut:

     csvcut source.csv --rename-columns geopos.coordinates.0:x,geopos.coornidates.1:y > dest.csv
    
  • Option 2: a separate tool:

     csvrename source.csv -c geopos.coordinates.0:x,geopos.coornidates.1:y > dest.csv
    

I have a working version of the latter in my repo. Please write what you think of this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions