postgresql - When copying from CSV how I do I had a field like the state the CSV is for? -


i know basic command copy voters '201702_vrdb_extract.txt' delimiter '\t'; want add "wa" state field each row of txt file.

my suggestion pre-process input file state field data. 1 simple way use awk ofs (output field separator) set tab following:

# assuming 5th field of input file state field awk '{ofs = "\t"; $5 = "wa"; print}' input.txt > inputstaterevised.txt 

in case don't have state field in existing input file, can append state field follows:

# assuming there total of 8 fields in original input file awk '{ofs = "\t"; $9 = "wa"; print}' input.txt > inputstateappended.txt 

Comments