Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7544181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:36:58+00:00 2026-05-30T08:36:58+00:00

I am using Postgres 8.4.4 copy, http://www.postgresql.org/docs/8.4/static/sql-copy.html , to import CSV data into my

  • 0

I am using Postgres 8.4.4 copy, http://www.postgresql.org/docs/8.4/static/sql-copy.html, to import CSV data into my database. Some of the values in my source data contain double-quotes which are getting stripped upon insertion whereas when I do an INSERT or UPDATE statement via psql for testing the double-quotes are retained. Maybe giving a clue as to what is going on, some values also contain commas which are retained as needed.

I have attempted to resolve the issue base on info in http://www.postgresql.org/docs/8.3/interactive/sql-syntax-lexical.html but have had no success.

The copy command I’m using is:

copy my_table (field_1, field_2, field_3 ...) from '/tmp/source.csv' with csv

The source data is double-quoted with comma separator. This can be changed if necessary…

“value”,”another value”,”this is “another” value”,”no more, thanks”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:36:59+00:00Added an answer on May 30, 2026 at 8:36 am

    You’ll have to quote the embedded quotes.
    Default is double them, so your data should be:

    "value","another value","this is ""another"" value","no more, thanks"
    

    The other way is to work unquoted (but you’ll have to quote the commas, if any), like

     value,another value,this is "another" value,no more, thanks
    

    UPDATE: This works, but you’ll have to make sure the embedded ‘”‘s are quoted (in this case by adding a backslash)

    DROP TABLE tmp.my_table CASCADE;
    CREATE TABLE tmp.my_table
            ( field_1 varchar
            , field_2 varchar
            , field_3 varchar
            , field_4 varchar
            );
    
    COPY tmp.my_table (field_1,field_2,field_3,field_4)
    FROM STDIN
    WITH CSV DELIMITER ',' QUOTE '"' ESCAPE '\'
            ;
    "value","another value","this is \"another\" value","no more, thanks"
    \.
            ;
    
    SELECT * FROM tmp.my_table;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to import a txt/csv file into my postgres database from php
I'm trying to copy the contents of one table into another in Postgres, however
im using Postgres 9.0 to save images into the database using 'lo_import' and to
I have some data files to import into a database with some unique delimiters:
My field is defined as follows COLUMNNAME character(9) I import CSV files using the
i am using hibernate annotations, at the back end i am using Postgres SQL
I have a 32-bit Windows/Qt application using Postgres plugin. Recently, I've been intrigued to
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using MySQL Administrator GUI tool I have exported some data tables retrieved from an
With doctrine syntax using postgres as database, is it possible to generate a query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.