db.columns: added format=list and format=csv #6971
Open
+93
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
examples, tests