Re: Copy from : ERROR: date/time field value out of range

From: "Jean-Christophe Arnu" <jcarnu(at)gmail(dot)com>
To: "David Tokmatchi" <david(dot)tokmatchi(at)gmail(dot)com>
Cc: pgsql-fr-generale(at)postgresql(dot)org
Subject: Re: Copy from : ERROR: date/time field value out of range
Date: 2007-07-30 14:59:24
Message-ID: 5b3af220707300759o629a0986ucebdfc4ebf375de4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale

Bonjour David,
AMHA, il serait plus optimum d'utiliser un via un coup de
sed/awk/perl/python (j'oublie personne) une date iso au format :
YYYY-mm-dd HH:MM:SS

Avec un sed (pas très élégant) on peut écrire :
cat fichieraplat.txt | sed -e
's/\([0-9][0-9]\)\.\([0-9][0-9]\)\.\([0-9][0-9][0-9][0-9]\)/\3-\2-\1/g'
> /tmp/fichiertransforme.txt

Cordialement,

--
Jean-Christophe Arnu

Le 30/07/07, David Tokmatchi<david(dot)tokmatchi(at)gmail(dot)com> a écrit :
>
>
> Bonjour
>
> J'utilise Copy pour charger les données depuis un fichier plat dans une
> table dont voici la description :
>
> Column | Type | Modifiers
> -----------+-----------------------------+-----------
> to_ref | bigint | not null
> to_entity | character(40) | not null
> to_date | timestamp without time zone | not null
> to_time | timestamp without time zone | not null
> to_occ | text |
>
> La commande copy est la suivante :
>
> copy toto from '/tmp/x.dat' delimiters '~'
>
> dans mon fichier x.dat il y a les données suivants ( un million
> d'enregistrement ):
> ...
> 3454495~TQKQD ~12.03.2007 00:00:00~01.01.1900 17:35:26~
> 3454496~HHKKF ~12.03.2007 00:00:00~01.01.1900 17:35:34~
> 3454497~BBIIL ~12.03.2007 00:00:00~01.01.1900 17:35:39~
> 3454501~IKKFFS ~12.03.2007 00:00:00~01.01.1900 17:43:16~
> 3454502~ADJUSTMENT ~12.03.2007 00:00:00~01.01.1900 17:44:33~
> 3454503~ADJUSTMENT ~12.03.2007 00:00:00~01.01.1900 17:46:16~
> 3454504~ADJUSTMENT ~12.03.2007 00:00:00~01.01.1900 17:47:52~
> 3454517~TFFFR ~13.03.2007 00:00:00~01.01.1900 08:53:20~
> ...
>
> L'erreur est la suivante :
> ERROR: date/time field value out of range: "13.03.2007 00:00:00"
> HINT: Perhaps you need a different "datestyle" setting.
> CONTEXT: COPY toto, line 89846, column to_date: " 13.03.2007 00:00:00"
>
> Pour info la ligne 89846 correspond a la dernière ligne de mes données.
>
> Merci pour vos lumières

In response to

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Eric Brison 2007-07-30 14:59:47 Re: Copy from : ERROR: date/time field value out of range
Previous Message Jean-Paul Argudo 2007-07-30 14:57:38 Re: Copy from : ERROR: date/time field value out of range