I am trying to import an Italian osm file into PostGIS with osm2pgrouting. I launched the script and it worked until it encountered an error. This is the output of osm2pgr:

Nodes table created
2create ways failed: 
Types table created
Way_tag table created
Relations table created
Relation_ways table created
Classes table created
Adding tag types and classes to database...
Adding relations to database...
Adding nodes to database...
Adding ways to database...
ERROR:  extra data after last expected column
CONTEXT:  COPY ways, line 681382: "934378       117     0.15808824934990467    11.1369311       45.8187991      11.1388487      45.818314100000002      37264295srid=432..."
Creating topology...
NOTICE:  CREATE TABLE will create implicit sequence "vertices_tmp_id_seq" for serial column "vertices_tmp.id"
CONTEXT:  SQL statement "CREATE TABLE vertices_tmp (id serial)"
PL/pgSQL function "assign_vertex_id" line 14 at EXECUTE statement
size of streets: 1072190
size of splitted ways : 2281124

I used the italy.osm.bz2 file decompressed finded here:
but have also tried with the one here:

I have tried different times, with different files -- in fact, I have been trying from almost a month, but nothing has changed: I always get the same error. Any suggestions?


1 Answer 1


Some of the road/way names in the OSM data seem to contain a backslash ("\") which they should not. This case is not tested and fixed by the "osm2pgrouting" tool so far and this most probably causes the error you get. What you could do is inserting the following line in the in the "exportWays" method in the "Export2DB.cpp" file (in the "src" folder of your "osm2pgrouting" folder) and after that build the tool again ("make"):

        std::string escaped_name = way->name;
        boost::replace_all(escaped_name, "\t", "\\\t");

        // This line needs to be added to remove backslashes from way names:
        boost::replace_all(escaped_name, "\\", "");

        boost::replace_all(escaped_name, "\n", "");
        boost::replace_all(escaped_name, "\r", "");
        row_data += escaped_name.substr(0,199);



  • Is there any fix for this issue in windows environment. As in windows env there is no Export2DB.cpp file avaiable. All there is one single osm2pgrouting.exe file
    – Lijo John
    Commented Oct 12, 2021 at 4:52

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.