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

support regex search/replace within columns #268

Closed
pstoll opened this issue Apr 7, 2014 · 2 comments
Closed

support regex search/replace within columns #268

pstoll opened this issue Apr 7, 2014 · 2 comments

Comments

@pstoll
Copy link

pstoll commented Apr 7, 2014

I've implemented an initial extension to csvgrep that allows specifying a search regex pattern and a replacement string (including references to groups via the regex pattern).

So as an example, given a CSV, this modifies column 1 by doing a
re.sub('-s flag', '-x flag', 'row[idx]') on each column specified via the -c flag.

cat 2007.csv | csvgrep -s '(\s+|[a-zA-Z])' -x '\1' -r '.' -c 1 | head

@onyxfish
Copy link
Collaborator

I probably won't accept a pull request for this, because I don't believe it makes sense to bring data modification tools into csvkit. It opens up a Pandora's box of "I just want a tool that makes X change to a cell." At a certain point it's just more sensible to use existing tools (code, Excel, whatever). I've resisted this temptation until now and so far haven't regretted it.

@onyxfish
Copy link
Collaborator

Rereading, I hope that didn't sound too dismissive. I love that you're hacking on it and if you wanted to make your own repo I'd be happy to link to you from the docs. :)

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