Thread: data type troubles

data type troubles

From
Kirk Wythers
Date:
I seem to be dealing with a data type issue when I try and import data into a new and empty database. 

Error Message: ERROR:  date/time field value out of range: "1332471600:00:00"
LINE 1: ...tc_avg25") values ('2012-03-22 21:00:00_B4WARM_A','133247160…

Here are the first two rows in the files I was sent. I cast ROWID as varchar32, TIME2 as time (I was told that TIME2 was a posix time value), and TIMESTAMP as timestamp. 

Any advice that would help me out of this hole is appreciated.

ROWIDTIME2TIMESTAMPBLOCKSTATNAMETABLEPROGRAMA_TC_AVG1A_TC_AVG10A_TC_AVG11A_TC_AVG12A_TC_AVG2A_TC_AVG3A_TC_AVG4A_TC_AVG5A_TC_AVG6A_TC_AVG7A_TC_AVG8A_TC_AVG9AIRTC_AVGECODE1ECODE10ECODE11ECODE12ECODE2ECODE3ECODE4ECODE5ECODE6ECODE7ECODE8ECODE9ETC_AVG13ETC_AVG14ETC_AVG15ETC_AVG16ETC_AVG17ETC_AVG18ETC_AVG19ETC_AVG20ETC_AVG21ETC_AVG22ETC_AVG23ETC_AVG24ETC_AVG25FLAG1FLAG10FLAG11FLAG12FLAG2FLAG3FLAG4FLAG5FLAG6FLAG7FLAG8FLAG9PAR_DEN_AVGPAR_TOT_TOTPERIOD10PERIOD11PERIOD12PERIOD13PERIOD14PERIOD15PERIOD16PERIOD9RAIN_IN_TOTRHS_TC_AVG1S_TC_AVG10S_TC_AVG11S_TC_AVG12S_TC_AVG2S_TC_AVG3S_TC_AVG4S_TC_AVG5S_TC_AVG6S_TC_AVG7S_TC_AVG8S_TC_AVG9SLR_MJ_TOTSLR_W_AVGSOILTEMP10_AVGSOILTEMP100_AVGSOILTEMP20_AVGSOILTEMP30_AVGSOILTEMP40_AVGSOILTEMP50_AVGSOILTEMP75_AVGVP_AVGVWC10VWC11VWC12VWC13VWC14VWC15VWC16VWC9WCODE1WCODE10WCODE11WCODE12WCODE2WCODE3WCODE4WCODE5WCODE6WCODE7WCODE8WCODE9WTC_AVG13WTC_AVG14WTC_AVG15WTC_AVG16WTC_AVG17WTC_AVG18WTC_AVG19WTC_AVG20WTC_AVG21WTC_AVG22WTC_AVG23WTC_AVG24WTC_AVG25
2012-03-22 21:00:00_B4WARM_A13324716001332471600   B4WARM_AB4WARM_AB4Warm_60CPU:B4warm2011_Sauron_ALT4.2.CR1NANANANANANANANANANANANA0NANANANANANANANANANANANANANANANANANANANANANANANANANANANANANANANANANANANANA0025.6324.7323.2723.8723.6325.0923.5921.7600NANANANANANANANANANANANA00NANANANANANANA00.2320.2060.1660.1820.1760.2160.1750.128NANANANANANANANANANANANANANANANANANANANANANANANANA

Re: data type troubles

From
Scott Marlowe
Date:
On Mon, Dec 17, 2012 at 2:38 PM, Kirk Wythers <wythe001@umn.edu> wrote:
>
> I seem to be dealing with a data type issue when I try and import data
> into a new and empty database.
>
> Error Message: ERROR:  date/time field value out of range:
> "1332471600:00:00"
> LINE 1: ...tc_avg25") values ('2012-03-22 21:00:00_B4WARM_A','133247160…
>
> Here are the first two rows in the files I was sent. I cast ROWID as
> varchar32, TIME2 as time (I was told that TIME2 was a posix time value), and
> TIMESTAMP as timestamp.
>
> Any advice that would help me out of this hole is appreciated.

Giant lines deleted.  OK, it looks like the 1332471600 is a unix
timestamp, not a SQL timestamp.

First thing I'd do is make a staging table to hold all these rows.
Declare that second field as bigint and so on, so you can load all
your rows at once.

After all the rows are loaded into a staging table, then you can start
using various pg functions to convert from unix timestamp to sql
timestamp etc.

http://www.postgresql.org/docs/8.4/static/functions-datetime.html

Search for the keyword "epoch" on that page for how to convert back
and forth from unix timestamps.