I’m trying to import a tab-delimited file using the PSql COPY command
copy TABLE(col1, col2, etc)
from /file.txt';
The problem is that some of my columns are empty. This includes the last column. I want empty values to be inserted as null, but this doesn’t seem to work for numeric fields, since it interprets the empty value as a blank string. The data looks something like this (I’ve replaced the tabs with | for readability
USGS|1012960|"name 1"|ST|47.15597778|-68.5743667|1|NAD83|563|||1010003|779|
USGS|1021050|"name 2"|ST|45.17|-67.2966667|5|NAD83||||1050001|1448|1448
The first sample row is missing the last value (there should be 14 columns in each row). COPY complains that there is missing data in the row. In other cases, missing data is represented by 2 |’s in a row. Some of these are Strings, which works fine. But others are numeric. Is there a way to tell COPY how to handle missing data?