<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Mangal;
        panose-1:2 4 5 3 5 2 3 3 2 2;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-CA link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hi,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I understand why would you be reluctant to do automatic
correction. However, the shapelib library, which shp2pgsql directly uses, does
do automatic correction. <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I agree: any mistake in the dbf should be reported. However, I
believe that, at the very least, a switch should be supported that allows
automatic conversion. <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I don’t quite understand your example :<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>“</span>if the field numeric in the shapefile instead of
be fill with numbers was filled with '1', '2', '3', etc...<br>
where the number are however not really numbers but text based, an action of
importing always 0.<br>
Will be more confusing. The user don't understand why a number (or
simil-number) became a '0'.”<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>In the DBF file itself, there is no difference between a ‘text-based
number’ and normal numbers. Whether I declare the column as numeric or
text, the data for the number one (1) will look the same. That will never be an
issue.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>It is interesting that you bring up other examples of corrupt
DBFs: I believe that shapelib actually handles some of those examples.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I agree with you that nothing should be ‘hidden’. I think
the behaviour should conform to shapelib, which it already mostly does. At the
very least, the DBF should be checked for this kind of corruption, and
reported.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>aman<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <b>On Behalf Of </b>Andrea
Peri<br>
<b>Sent:</b> August 14, 2010 3:18 AM<br>
<b>To:</b> PostGIS Users Discussion<br>
<b>Subject:</b> [postgis-users] shp2pgsql fails on malformed integer attribute<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>>  aman.verma at <a
href="http://mcgill.ca">mcgill.ca</a>  wrote..<br>
>If you use shp2pgsql to upload a shapefile with an attribute table that has
a malformed integer <br>
>(like a letter), shp2pgsql will not correct it, and the upload will fail.<br>
>Normally, I would view this as 'expected behaviour' (garbage in, garbage
out). However, I have two <br>
>reasons to believe that shp2pgsql should do the correction:<br>
>1) ArcGIS, and other software that read the xBase format (DBF), interpret
such malformed integers as 0. <br>
>There seem to be a lot of shape files floating around that have malformed
integers in them, precisely <br>
>because they appear to be working. Users may have a difficult time understanding
why shp2pgsql keeps <br>
>trying to upload 'g' when all they can see is '0'.<br>
<br>
I think this is not a good strategy.<br>
<br>
If there a mistake in the dbf the mistake must be reported, not hide resolving
automatically it.<br>
Otherwise the shapefile version became not-interoperability.<br>
Just now often the gis user was speaken about "shapefile read from
arcgis" or some other tools, as they was difference from other kind of
shapefile.<br>
<br>
I experience many situation where a shapefile send me from other users are
wrong, and the user report me "but my tool read it so for me it is 
ok."<br>
<br>
This may be born many kinds of formats shapefiles difference each other.<br>
So the shapefile format "became an opinion", and every tool apply
they specific changing to the format.<br>
For example<br>
<br>
what if a filed name was more then 10 character ?<br>
what if a text field was more character of how much declared in the header ?<br>
what if a date field was filled with a number ?<br>
and so on .....<br>
<br>
Even in your case:<br>
<br>
if the field numeric in the shapefile instead of be fill with numbers was
filled with '1', '2', '3', etc...<br>
where the number are however not really numbers but text based, an action of
importing always 0.<br>
Will be more confusing. The user don't understand why a number (or
simil-number) became a '0'.<br>
<br>
Andrea.<br>
<br>
-- <br>
-----------------<br>
Andrea Peri<br>
. . . . . . . . . <br>
qwerty אטלעש<br>
-----------------<o:p></o:p></p>

</div>

</body>

</html>