[postgis-users] Changing transaction behaviour in shp2pgsql -summary

Ralf Suhr Ralf.Suhr at itc-halle.de
Mon Mar 15 02:55:00 PDT 2010


I use the external recoding for shapefiles and other sql files witch are in 
LATIN9. The postgres recoding to utf-8 sometimes fail.
The external program "recode" do a lazy recoding and that output is accepted 
by postgres.

Maybe the problem occurs only für me.

Gr Ralf

Am Montag 15 März 2010 10:02:13 schrieb Paragon Corporation:
> Ralf,
> 
> Apologize if you tried this already since we are entering the conversation
> late.
> 
> Are you sure your shapefiles are in UTF-8.  The -W switch you give to
> shp2pgsql has to be the encoding of the shapefile not the encoding of the
> database.
> The reason is that shp2pgsql converts from the source encoding -W to the
> UTF-8 and then does a SET client_encoding UTF-8 during load as I recall.
> 
> So I would assume your shapefile are in LATIN-1 or WIN something or other
> in which case
> 
>      shp2pgsql -s 28350 -W "latin1"
> 
> Might work better.
> 
> Hope that helps,
> Leo and Regina
> http://www.postgis.us
> 
> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Ralf
> Suhr
> Sent: Monday, March 15, 2010 4:38 AM
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] Changing transaction behaviour in shp2pgsql
> -summary
> 
> Hello Ben,
> 
> I'm doing recoding of shapefiles without postgres when postgres can not do
> so.
> 
> shp2pgsql [...] | recode shapefile_encoding..utf8 | psql database.
> 
> Gr Ralf
> 
> Am Montag 15 März 2010 00:51:00 schrieb Ben Madin:
> > Thanks all for the feedback - to summarise :
> > 
> > shp2pgsql - Currently, all output is 'chunked' transactions - changing
> > this behaviour not currently supported. - A patch could be provided to
> > shp2pgsql to do this.
> > 
> >  - The suggestion is a -T switch with options such as single, chunked,
> > 
> > no transactions. - I'm happy to look at submitting a patch... but it
> > won't be until after I've submitted my thesis ...
> > 
> > The text editor approach is to direct output into a file and find /
> > replace the BEGIN / COMMIT lines.
> > 
> > The on-the-fly alternative is to use a pattern matching program, with
> > two solutions offered :
> > 
> > Using sed (thanks Brent)
> > 
> >     shp2pgsql -s 28350 -W UTF8 \
> >     /Users/owner/Spatial/country/AUS/WA/MRWA/mrwa_network.shp \
> >     gis.mrwa_gda94 | sed 's/BEGIN//' | sed 's/COMMIT//' psql australia
> > 
> > Using grep (thanks Steve)
> > 
> >     shp2pgsql ... | grep -v BEGIN | grep -v COMMIT | psql australia
> > 
> > cheers
> > 
> > Ben
> > 
> > On 15/03/2010, at 4:35 , strk wrote:
> > > On Sun, Mar 14, 2010 at 04:58:02PM +0700, Ben Madin wrote:
> > >> in the event I can't work out the encoding, is there any way to
> > >> turn off the transaction behaviour, ie I'm happy to miss 4 records,
> > >> but not 1000 as a result of the transactions being aborted. (short
> > >> of putting it all into a text file and removing all the begin and
> > >> commit commands...)
> > > 
> > > Feel like working on a patch to make "transaction policy" selectable
> > > with a switch ?
> > > 
> > >  -T <policy> transaction policy (single*,none)
> > > 
> > > Current policy is chunked, dunno for what rationale..
> > > 
> > > --strk;
> > > 
> > >  ()   Free GIS & Flash consultant/developer
> > >  /\   http://strk.keybit.net/services.html
> > > 
> > > _______________________________________________
> > > postgis-users mailing list
> > > postgis-users at postgis.refractions.net
> > > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list