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.03k stars 603 forks source link

csvsql UPDATE query not working? #1223

Closed johnathanz closed 1 year ago

johnathanz commented 1 year ago

This looks to be the issue that was solved in https://github.com/wireservice/csvkit/issues/952

I'm trying to update rows in the attached csv that when dwl = 'np', I update the value to 0. input.csv

I used: csvsql --query "update input set dwl = '0' where dwl = 'np'" input.csv

No error from the terminal, but nothing is changed in the file either.

Any idea what I'm doing wrong?

@jpmckinney FYI...

Thanks!

jpmckinney commented 1 year ago

An UPDATE SQL statement produces no output, hence csvkit also produces no output. You need to instead SELECT all rows after the UPDATE, e.g.

csvsql --query "update input set dwl = '0' where dwl = 'np'; SELECT * FROM input" input.csv
johnathanz commented 11 months ago

Thanks @jpmckinney!