# Array Design Question

#1

Here is the csv file data, the 24 hour temperature @ an airport for a day.

``````1000,08/13/2007,6,6,5,4,5,4,6,8,0,1,2,5,6,7,7,6,6,5,3,1,9,6,4,3
1001,08/14/2007,6,6,5,6,5,4,6,8,0,1,2,5,6,7,7,6,6,5,3,1,9,6,4,4``````

I create the schema like this to load this data.

``````CREATE EMPTY ARRAY hrly_temp_load
<
airport : int64,
ts : datetime,
hr00 : double,
hr01 : double,
hr02 : double,
hr03 : double,
hr04 : double,
hr05 : double,
hr06 : double,
hr07 : double,
hr08 : double,
hr09 : double,
hr10 : double,
hr11 : double,
hr12 : double,
hr13 : double,
hr14 : double,
hr15 : double,
hr16 : double,
hr17 : double,
hr18 : double,
hr19 : double,
hr20 : double,
hr22 : double,
hr23 : double,
hr24 : double
>
[ Line=0:*,1000,0 ]``````

I like to redimension this hrly_temp_load to hrly_temp which has 3 dimensions, airport, ts and hrs. What is the best way to do this?
I would like to know how to convert the attribute list hr[00-24] to a dimension.

I would like to redimension the above to the schema to the below

[code]CREATE EMPTY ARRAY hrly_temp
<
val : double

[ airport=0:,10000,0, ts(datetime)=,3650000,0, hrs:0:24,24,0 ][/code]

Thank you,
Vijay

#2

Hi Vijay,

Here’s a thought:

``````redimension_store(
apply(
cross(
build(<hrs:int64>[x=0:23,24,0], x)
),
val,
iif(hrs = 0, hr00,
iif(hrs = 1, hr01,
iif(hrs = 2, hr02,
...
hr24)))
),
hrly_temp
)``````

This is one of those cases where a cartesian product (cross) works unexpectedly well. Let me know if this works for you…

#3

I was wondering how cross is going to be used and this is a good example. I re-organized the data in awk to loaded it. But I liked the technique.

Thank you,
Vijay