django-postgres-copy icon indicating copy to clipboard operation
django-postgres-copy copied to clipboard

Support for point fields / multiple csv columns to one field

Open ndanielsen opened this issue 8 years ago • 3 comments

Great project! I love it! Wondering if i can import a csv that contains geographical data.

For example, something like this

c = CopyMapping( MyModel, "./data.csv", dict(point=['x', 'y'], number='NUMBER') ) c.save()

Here's a row from the dataset for example: ['-77.0297110577', '38.9291522717', '11802074', '8330232', 'False', 'P173', 'NO PARKING STREET CLEANING', '3200 BLOCK 13TH ST NW EAST SIDE', 'DC', '4D', '806540', '5618.0', '397424', '140141', 'Parking_Violations_in_April_2010.csv', '2010-04-06T09:39:00.000Z']

ndanielsen avatar Jul 25 '16 02:07 ndanielsen

Hmm. I never thought to try this. What happens if you preformat the points as WKT format or something that PostGIS expects?

palewire avatar Jul 25 '16 20:07 palewire

+1 It looks like this, or something pretty close to it, would work--see this SO answer. A few years ago I was doing something comparable by using django.contrib.gis.geos.GEOSGeometry -- for a geosgeometry g, g.hex work(ed), though I can't remember why I went that route.

jsfenfen avatar Oct 11 '16 16:10 jsfenfen

I'm all for trying it, I just want the API syntax we select to be as clear as possible. Generally this library is modeled on the layout of Django's LayerMapping tool for loading shapefiles. You see anything there we could crib from?

palewire avatar Oct 11 '16 16:10 palewire