Re: Import CSV date issues

From: Sarfraz Nawaz <sarfraz(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Import CSV date issues
Date: 2013-03-03 20:48:26
Message-ID: CACDibgEYXQZXf_onchKXH4q36t3dVQtRKdHQ9=PSGiwZxhLOjA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Tom you are a legend! There were invisible characters at the start of
the file which were not being shown with "head" and "cat". Removing
them fixed the issue and copy worked like a charm. Thank you!

On Sun, Mar 3, 2013 at 3:05 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Sarfraz Nawaz <sarfraz(at)gmail(dot)com> writes:
>> However, when I try to import data into "durations" table from a CSV
>> file, I get this error which is puzzling me because the date in the
>> CSV file is in the same DMY format that the db should be expecting. I
>> have also tried by giving "durations(startdate, enddate, ....)" format
>> as well but same result.
>
>> mydb=> \copy durations FROM 'myfile.csv' DELIMITER ',' CSV;
>> ERROR: invalid input syntax for type date: "12/09/2011"
>> CONTEXT: COPY durations, line 1, column startdate: "12/09/2011"
>
> That certainly *looks* right, and it does work in testing here.
> However, since this is the first column of the first line of the
> file, my bet is that you've got some invisible characters at the
> start of the file that are screwing up COPY. Text editors that
> think they should put UTF8 "BOM" marks into text files are a
> frequent cause of this on Windows.
>
> regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Merlin Moncure 2013-03-04 14:47:21 Re: Import CSV date issues
Previous Message Tom Lane 2013-03-03 15:05:17 Re: Import CSV date issues