How can I write a stored procedure that imports data from a CSV file and populates the table?
相关问题
- sqlyog export query result as csv
- Django distinct is not working
- PostgreSQL: left outer join syntax
- Connecting Python to a Heroku PostgreSQL DB?
- PostgreSQL - Deleting data that are older than an
相关文章
- postgresql 关于使用between and 中是字符串的问题
- postgresql 月份差计算问题
- Using boolean expression in order by clause
- Table valued Parameter Equivalent in Postgresql
- in redshift postgresql can I skip columns with the
- How to read local csv file in client side javascri
- Oracle equivalent of PostgreSQL INSERT…RETURNING *
- PostgreSQL field data type for IPv4 addresses
Create table and have required columns that are used for creating table in csv file.
Open postgres and right click on target table which you want to load & select import and Update the following steps in file options section
Now browse your file in filename
Select csv in format
Encoding as ISO_8859_5
Now goto Misc. options and check header and click on import.
As Paul mentioned, import works in pgAdmin:
right click on table -> import
select local file, format and coding
here is a german pgAdmin GUI screenshot:
similar thing you can do with DbVisualizer (I have a license, not sure about free version)
right click on a table -> Import Table Data...
If you don't have permission to use
COPY
(which work on the db server), you can use\copy
instead (which works in the db client). Using the same example as Bozhidar Batsov:Create your table:
Copy data from your CSV file to the table:
You can also specify the columns to read:
One quick way of doing this is with the Python pandas library (version 0.15 or above works best). This will handle creating the columns for you - although obviously the choices it makes for data types might not be what you want. If it doesn't quite do what you want you can always use the 'create table' code generated as a template.
Here's a simple example:
And here's some code that shows you how to set various options:
Take a look at this short article.
Solution paraphrased here:
Create your table:
Copy data from your CSV file to the table: