Re: copy in date string "00-00-00 00:00:00"

Поиск
Список
Период
Сортировка
От Martin Gregorie
Тема Re: copy in date string "00-00-00 00:00:00"
Дата
Msg-id 1331799899.15175.142.camel@zappa.gregorie.org
обсуждение исходный текст
Ответ на Re: copy in date string "00-00-00 00:00:00"  (Mark Phillips <Mark.Phillips@mophilly.com>)
Список pgsql-general
On Wed, 2012-03-14 at 21:52 -0700, Mark Phillips wrote:
> I am not familiar with sed, except for some trivial bits I nicked off
> the web. Enough to know it works, and to be dangerous. Nonetheless,
> using SED may be the way to go as there are two tables that contain a
> bit over 3,000,000 rows each.
>
You should also consider using awk/gawk with the field separator (FS
variable) set to match the one in your input (','). The advantages in
this case are that it can be made to work on specific fields in the CSV
file and not look at the rest, something like:

BEGIN { FS = ','; }                      # set field sep to comma
$5 == '0000-00-00 00:00:00' { $5 = '' }  # empty field 5 if it matches
                            {print }     # output all lines

Disclaimer: this is untested example code


Martin






В списке pgsql-general по дате отправления:

Предыдущее
От: Alexander Reichstadt
Дата:
Сообщение: Re: pg_role vs. pg_shadow or pg_user
Следующее
От: Richard Harley
Дата:
Сообщение: Backups