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

concat throws an error if the first supplied file is empty #259

Closed
4 tasks
MostafaYA opened this issue Nov 14, 2023 · 3 comments
Closed
4 tasks

concat throws an error if the first supplied file is empty #259

MostafaYA opened this issue Nov 14, 2023 · 3 comments

Comments

@MostafaYA
Copy link

Prerequisites

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

Describe your issue

  • describe the problem
  • provide a reproducible example
#generate files
echo -e "1,2,3\n1,2,3" > data1.csv 
echo -e "4,5,6\n4,5,6" > data2.csv 
touch empty.csv

#concat files  (first file is not empty)
csvtk concat -H data1.csv data2.csv empty.csv 
[WARN] csvtk concat: skipping empty input file: empty.csv
1,2,3
1,2,3
4,5,6
4,5,6

#concat files  (first file is empty)
csvtk concat -H empty.csv data1.csv data2.csv
[WARN] csvtk concat: skipping empty input file: empty.csv
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/shenwei356/csvtk/csvtk/cmd.glob..func5(0x180a3a0?, {0xc000539180, 0x3, 0x4})
        /home/shenwei/go/src/github.com/shenwei356/csvtk/csvtk/cmd/concat.go:129 +0x929
github.com/spf13/cobra.(*Command).execute(0x180a3a0, {0xc0005390c0, 0x4, 0x4})
        /home/shenwei/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x1809820)
        /home/shenwei/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /home/shenwei/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
github.com/shenwei356/csvtk/csvtk/cmd.Execute()
        /home/shenwei/go/src/github.com/shenwei356/csvtk/csvtk/cmd/root.go:72 +0x25
main.main()
        /home/shenwei/go/src/github.com/shenwei356/csvtk/csvtk/main.go:59 +0x17

Thank you

I'm grateful to users who have greatly helped to report bugs and suggested new features.

I may respond to issues or fix bugs quickly, but I usually implement new features periodically (two or more weeks).

@shenwei356
Copy link
Owner

Thanks for reporting this. I've fixed it last week.

csvtk_darwin_amd64.tar.gz
csvtk_darwin_arm64.tar.gz
csvtk_linux_amd64.tar.gz

@MostafaYA
Copy link
Author

This seems not resolved and depends of the order of input files. If first file is empty, it says 'no input data'

#data
echo -e "1,2,3\n1,2,3" > data1.csv 
echo -e "4,5,6\n4,5,6" > data2.csv 
touch empty.csv

$ csvtk concat -H data1.csv data2.csv empty.csv 
[WARN] csvtk concat: skipping empty input file: empty.csv
1,2,3
1,2,3
4,5,6
4,5,6

$ csvtk concat -H empty.csv data1.csv data2.csv
[WARN] csvtk concat: skipping empty input file: empty.csv
[WARN] csvtk concat: no input data

@shenwei356
Copy link
Owner

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

No branches or pull requests

2 participants