[GIS] Loading data onto PostGIS using KML files with attibute data

csvkmlpostgispostgresqlshapefile

So, I have a kml file which contains 317 data points (317 polygons and the respective 317 names). The kml file also contains attribute data which pops up in a bubble on Google earth with about 12 custom data points (Code, name, locality, no. of houses etc.) which could have been loaded onto the kml file using ArcGIS (I'm assuming this, cause I received just the kml file from my source) or could have been custom coded using a text editor.

Now, I'm trying to build a PostGIS db using this data along with the custom data points (attribute data) which is stored in the kml file. I tried converting the kml file to a shapefile to load it onto PostGIS using shp2pgsql, but this ignores all the attribute data. Only the geometry and name gets converted. I also tried converting the KML file to xml/csv/xls format to atleast try and merge the attribute data with the main db on postgresql, but I failed cause there is no converter out there which pulls out all the data from a KML file.

My question is, is there a way to load this kml file with attribute data onto PostGIS? Is there a simpler converter for KML to CSV, or similar spreadsheet formats? What's the best way to do this?

Best Answer

I'm not sure what software you're using but when I covert the Google Campus Layer in the Google Sample KML file to a shapefile with QGIS, all the attributes are maintained. What software are you using?