I'm trying to use PostGIS Shapefile Import/Export Manager to import a shapefile that was created in QGIS. The shapefile has all the blocks of the 2010 U.S. Census for Oregon and was exported as a polygon from a TIGER database that came from the U.S. Census website.

I was having one problem with the shapefile not importing and fixed that with the first answer from this question, i.e. I needed to create a postgis extension in the PostgreSQL database I wanted to work in.

Now, I get a new error when I click on "Import". I get the following error message:

Importing with configuration: or_census_popdens, public,  , D:\data\data\PostgreSQL\data\OR_census_popdens.shp, mode=c, dump=1, simple=0, geography=0, index=1, shape=1, srid=4326
Shapefile type: Polygon
Failed in pgui_copy_start(): ERROR:  syntax error at or near ")"
LINE 1: ...","area_ha","popdens_ha","area_sqmi","popd_sqmi", ) FROM std...

Shapefile import failed.

It seems there is some kind of end of file problem with the attribute table? In the attribute table itself, "popd_sqmi" is the final column, but the code for the error shows a "," trailing that column and just before the closing ")" in the command . I don't know exactly what is causing this error though. How should I fix this?

  • 2
    It looks like the field list in the insert statement has a trailing comma. Can you share the names of all the fields in your shape file? Maybe one of them has an accented character or something?
    – wfgeo
    Commented Dec 29, 2019 at 6:34
  • 1
    Did you this action using shp2pgsql postgis function shp2pgsql -I -s SRDI "SHPname.shp" public.tbname | psql -U <postresql_username> -d <postgis_databae>; or could you share the link to your .shp file?
    – ArashMad
    Commented Dec 29, 2019 at 9:08
  • John, future users may have the same problem. If you write an answer and accept it, instead of edit your question, future users with the same problem will be able to find your solution. Your question, as is now edited, must be closed because the change of the conditions which turns obsolete the question. Commented Dec 29, 2019 at 21:11
  • @GabrielDeLuca well, I made another edit. I suppose I can edit again and write the part past the edit as an answer.
    – John Polo
    Commented Dec 29, 2019 at 21:22
  • @wfgeo thanks for your help. I don't have enough rep to vote up your comment, since I found it helpful.
    – John Polo
    Commented Dec 29, 2019 at 21:27

1 Answer 1


wfgeo's comment reminded me of a join I made between the shapefile and a text file/table I had added in QGIS. All of the column names in the joined shapefile that wouldn't import are: OBJECTID,GEOID,SUFFIX,NAME,ALAND,AWATER,INTPTLAT,INTPTLON,OR_pop_fie,OR_pop_sta,OR_pop_cou,OR_pop_tra,OR_pop_blo,OR_pop_P01,area_ha,popdens_ha,area_sqmi,popd_sqmi


exported to a stand-alone shapefile (it was part of a TIGERLines DB from U.S. Census found here), and I was able to import the file with PostGIS import tool. I'm not sure what in the column names of the joined shapefile would create the problem I had. There were no special characters, which was a possibility alluded to by wfgeo in their comment.

So I can import the original unjoined shapefile with PostGIS, but not the new one I created when I made a join with another table. It's the shapefile that includes the join that I'd like to get in to PostGIS. I will import the unjoined shapefile with PostGIS and I suppose I can import the table separately into PostgreSQL and join there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.