Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux