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

Implement glob support for Windows shells (which don't do this themselves) #634

Closed
tc-ying opened this issue Jun 30, 2016 · 11 comments · Fixed by #1254
Closed

Implement glob support for Windows shells (which don't do this themselves) #634

tc-ying opened this issue Jun 30, 2016 · 11 comments · Fixed by #1254
Labels
Milestone

Comments

@tc-ying
Copy link

tc-ying commented Jun 30, 2016

Is there a way to group " *.csv " in a directory by --filenames ? If I pass the CSVs into csvstack using stdin, then their group names become .

Forgive this newbie question.

@jpmckinney
Copy link
Member

Can you share the complete command that you're running?

@tc-ying
Copy link
Author

tc-ying commented Jul 1, 2016

Since this is not permissible — csvstack --filenames "*.csv"

Let's do it in windows command : type "to_append*.csv" | csvstack --filenames "master.csv" -

Output is something like :

group,header1,header2
master.csv,col1,col2
,col1,col2
,col1,col2

Can't figure how to stack a batch of CSVs at one command.

@jpmckinney
Copy link
Member

Why isn't csvstack --filenames "*.csv" permissible?

If the file comes from stdin, then it doesn't have a filename. That's just UNIX; csvkit can't fix that.

@tc-ying
Copy link
Author

tc-ying commented Jul 4, 2016

Using wildcard file names generates "error: You must specify at least two files to stack."

Its seems most csvkit commands do not accept wildcard file arguments. It makes batch csvstack less convenient coz I can't figure out a FOR... DO loop for csvstack.

@jpmckinney
Copy link
Member

That error no longer exists in the current code base. Try the latest csvkit:

pip install --upgrade -e git+git://github.com/onyxfish/csvkit.git@master#egg=csvkit

I can re-open if it still doesn't work with the latest version.

@tc-ying
Copy link
Author

tc-ying commented Jul 6, 2016

It now works with ONE argument 👍 , but if that argument is :

INPUT – csvstack "*.csv"
OUTPUT – [Errno 22] Invalid argument: '*.csv'

Accepting wildcard argument seems to require fundamental program change.

@jpmckinney
Copy link
Member

What operating system are you on?

@jpmckinney jpmckinney reopened this Jul 6, 2016
@tc-ying
Copy link
Author

tc-ying commented Jul 6, 2016

UPDATE :

Windows command prompt seems not to support wildcard argument. An option to stack all CSVs under a directory is most handy for Windows...

@jpmckinney jpmckinney changed the title Csvstack - Group a lot of CSVs in a folder by respective filenames Windows apparently doesn't support globs: add workaround Jul 14, 2016
@tc-ying
Copy link
Author

tc-ying commented Aug 1, 2016

users may switch to run .sh scripts in windows...

shopt -s nullglob
files=(*.csv)
csvstack "${files[@]}" > merged.csv

done.

@tc-ying tc-ying closed this as completed Aug 1, 2016
lcorbasson pushed a commit to lcorbasson/csvkit that referenced this issue Sep 7, 2020
lcorbasson pushed a commit to lcorbasson/csvkit that referenced this issue Sep 7, 2020
@ilovefreesw
Copy link

2024 and still doesn't work
image

@jpmckinney jpmckinney reopened this May 29, 2024
@jpmckinney jpmckinney added this to the Priority milestone May 29, 2024
@jpmckinney
Copy link
Member

We can do something like Click did: https://github.com/pallets/click/pull/1830/files

@jpmckinney jpmckinney changed the title Windows apparently doesn't support globs: add workaround Implement glob support for Windows shells (which don't do this themselves) May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants