Select specific Fields to output to CSV - Postgresql

csv postgresql sqlbulkcopy

Question

I have a database from which i have to export to a csv/text file the longtitude and lantitude in this form:

25.767368,-80.18930
34.088808,-118.40612
40.727093,-73.97864

# Lat,Long

The attributes in my database are in a correct format and i only need the export. As my knowledge of working straight with Databases is limited i only got to this point:

COPY (Select * From users) To '/Users/tmj/Desktop/text.csv' With CSV;

Which just dumps the entire database in a csv..

How can i select the 2 attributes i need and have them outputted in the correct format (lat,long)?

1
0
8/25/2014 9:47:55 AM

Accepted Answer

COPY (Select latitude,longitude From users) To '/Users/tmj/Desktop/text.csv' With CSV;
2
8/25/2014 9:55:19 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow