wireservice / csvkit

A suite of utilities for converting to and working with CSV, the king of tabular file formats.
https://csvkit.readthedocs.io
MIT License
6.01k stars 603 forks source link

csvsed (or csvgrep with replace) #1057

Open geekscrapy opened 4 years ago

geekscrapy commented 4 years ago

An idea, have a sed like module within csvkit. This would allow grepping based on columns, and also (more importantly) replacing values in certain columns based on regex.

Must haves:

Nice to haves:

I may have a use-case for this in the near future but logging it here incase someone thinks its needed and wants to take a crack before me!

jpmckinney commented 4 years ago

Hi @geekscrapy, to keep the maintenance burden reasonable, we aren't adding new tools to csvkit. That said, people can certainly create their own Python packages to offer new CSV tools!

geekscrapy commented 4 years ago

Many thanks, I'll probably be looking into this in the next few months so may have a pull request coming 👍

jpmckinney commented 4 years ago

I just remembered: have a look at https://github.com/johnkerl/miller, which I think has the feature you're looking for (miller put).

jpmckinney commented 6 months ago

Just a note that csvsql can be used to query and modify CSV files, see e.g. #1243

jpmckinney commented 6 months ago

csvmedkit has a csvsed command, which might not be too much effort to add as an option to csvgrep: https://github.com/dannguyen/csvmedkit/blob/main/csvmedkit/utils/csvsed.py Can also look at https://pypi.org/project/csvsed/

That said, see comments in #268. Also, qsv already has a replace command.

This can maybe be used to resolve #396 (#530 #814)