db.columns: added format=list and format=csv#6971
Conversation
I don't think so, it's valid and harmless. The issue is that csv format makes really sense only together with the -e flag, so we could potentially restrict the user to use the csv format only with the -e flag, or automatically turn on the -e flag with csv. At this point, just leave it the way you have it, it's consistent behavior that way, just maybe don't show example of csv without -e in the documentation. |
|
Thank you!
Ok I have now added the tests and docs. I have included examples of list and csv format with -e only, as I think this is what user will use with these formats. As without -e flag, list, csv and plain gives almost same output except header name. |
|
Thank you for the review! I have added a new heading in the doc with I have renamed the file name too. And removed some redundant docs. |
petrasovaa
left a comment
There was a problem hiding this comment.
I took the liberty to update and reorganize the documentation. Ready for merge, thank you!
Fixes #6072
Added an option
separatorto db.columns which will be field separator in case of CSV and LIST format, but will be error in JSON and PLAIN format.Also, I have rearranged declaration of some variables, so that to avoid re-declaring in each switch case block.
default separator=newline
grass > db.columns zipcodes format=list cat OBJECTID WAKE_ZIPCO PERIMETER ZIPCODE_ ZIPCODE_ID ZIPNAME ZIPNUM ZIPCODE NAME SHAPE_Leng SHAPE_Areadefault separator=newline
grass > db.columns zipcodes format=list -e cat INTEGER OBJECTID INTEGER WAKE_ZIPCO DOUBLE PRECISION PERIMETER DOUBLE PRECISION ZIPCODE_ DOUBLE PRECISION ZIPCODE_ID DOUBLE PRECISION ZIPNAME CHARACTER ZIPNUM DOUBLE PRECISION ZIPCODE CHARACTER NAME CHARACTER SHAPE_Leng DOUBLE PRECISION SHAPE_Area DOUBLE PRECISIONdefault separator=comma
grass > db.columns zipcodes format=csv -e name,sql_type,is_number cat,INTEGER,true OBJECTID,INTEGER,true WAKE_ZIPCO,DOUBLE PRECISION,true PERIMETER,DOUBLE PRECISION,true ZIPCODE_,DOUBLE PRECISION,true ZIPCODE_ID,DOUBLE PRECISION,true ZIPNAME,CHARACTER,false ZIPNUM,DOUBLE PRECISION,true ZIPCODE,CHARACTER,false NAME,CHARACTER,false SHAPE_Leng,DOUBLE PRECISION,true SHAPE_Area,DOUBLE PRECISION,trueseparator is of no effect
In case of format=csv and without -e: the separator has no role, should we give warning to user?
TODO: