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

del-header removes empty cells when the input is one column #238

Closed
2 tasks done
alvanuffelen opened this issue Aug 1, 2023 · 3 comments
Closed
2 tasks done

del-header removes empty cells when the input is one column #238

alvanuffelen opened this issue Aug 1, 2023 · 3 comments
Labels

Comments

@alvanuffelen
Copy link

Prerequisites

  • make sure you're are using the latest version by csvtk version
  • read the usage

Describe your issue

csvtk del-header on one column removes the empty cells.
example.txt

Empty cells are included:

cat example.txt | csvtk cut -f species

Empty cells are removed:

cat example.txt | csvtk cut -f species | csvtk del-header
@shenwei356
Copy link
Owner

Hmm, they are treated as empty rows and skipped since v0.26.0.

This is problematic in your situation, I should make it optional with

 -E, --ignore-empty-row       ignore empty rows

@shenwei356 shenwei356 added the bug? label Aug 2, 2023
@shenwei356
Copy link
Owner

shenwei356 commented Aug 9, 2023

That's sad, the official csv reader skip blank lines by default, and no option to disable this.

https://pkg.go.dev/encoding/csv

Blank lines are ignored. A line with only whitespace characters (excluding the ending newline character) is not considered a blank line.

Some guys tried to change this but failed., the PR was not accepted.

@shenwei356
Copy link
Owner

shenwei356 commented Aug 11, 2023

A workaround way: add the row number with the global flag -Z/--show-row-num, which would stop del-header removing blank lines

$ cat example.txt | csvtk cut -f species -Z | csvtk del-header | csvtk cut -f  -1 | wc -l
162

$ cat example.txt | wc  -l
163

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

No branches or pull requests

2 participants