Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add header command #62

Closed
avilella opened this issue Jan 17, 2019 · 3 comments
Closed

add header command #62

avilella opened this issue Jan 17, 2019 · 3 comments

Comments

@avilella
Copy link

avilella commented Jan 17, 2019

Would it be possible to have an add header(s) command to csvtk, if there isn't an easy way to do it yet?

E.g.

cat file.csv
1
2
3
4

csvtk add-header -f 1:myheader file.csv
myheader
1
2
3
4

Thanks in advance for considering. I wanted a more elegant way than the following for 1-column files:

{ echo myheader ; cat file.csv ; }
@shenwei356
Copy link
Owner

Ok, I need this too

shenwei356 added a commit that referenced this issue Jan 19, 2019
shenwei356 added a commit that referenced this issue Jan 19, 2019
@shenwei356
Copy link
Owner

Added:

Examples:

$ seq 3 | csvtk mutate -H | csvtk add-header -n a,b
a,b
1,1
2,2
3,3

$ seq 3 | csvtk mutate -H -t | csvtk add-header -t -n a,b
a       b
1       1
2       2
3       3

@shenwei356
Copy link
Owner

shenwei356 commented Jan 19, 2019

csvtk del-header is added too, you can also use sed 1d in *nix.

Adding a global option to disable outputting header line is an optional way, but it need to change all codes of commands, so I just add a new command to to this.

$ seq 3 | csvtk mutate -H | csvtk add-header -n a,b | csvtk del-header 
1,1
2,2
3,3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants