The answer below gives you what you asked for but if all the data in
the csv file is numeric then you are probably better to remove the
boxing:

   a2=: >a
   b=.  ({. + i.@>:@-~/) 0 _1 { {."1 a2
   b ,. (b e. {."1 a2) #inv!.0 (}."1 a2)

To get a2 from a csv file the following should do the job
   a2=: makenum readcsv 'yourfilename.csv'

On Fri, Oct 14, 2011 at 6:03 PM, Ric Sherlock <[email protected]> wrote:
> Not very elegant but works until someone comes up with something better
>
> b=: <"0 ({. + i.@>:@-~/) > 0 _1 { {."1 a
> b ,. (b e. {."1 a) #inv!.(<0) (}."1 a)
>
> On Fri, Oct 14, 2011 at 4:46 PM, PackRat <[email protected]> wrote:
>> Here's some faux stock market data for July 1-11, 2011:
>>
>>   a=. 77247;1;2;3;4;5;6
>>   a=. a,.(77251;1;2;3;4;5;6)
>>   a=. a,.(77252;1;2;3;4;5;6)
>>   a=. a,.(77253;1;2;3;4;5;6)
>>   a=. a,.(77254;1;2;3;4;5;6)
>>   a=. a,.(77257;1;2;3;4;5;6)
>>   a=. |: a
>>
>>   a
>> +-----+-+-+-+-+-+-+
>> |77247|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77251|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77252|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77253|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77254|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77257|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>>
>> The above is how the data appears after reading it in from a CSV file.
>>
>> As you may note, there are missing dates due to market closures for
>> weekends and holidays.  I'd like to insert zeroed data so that every
>> daynum is accounted for.  Here's what I'd like the result to look like:
>>
>> +-----+-+-+-+-+-+-+
>> |77247|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77248|0|0|0|0|0|0|
>> +-----+-+-+-+-+-+-+
>> |77249|0|0|0|0|0|0|
>> +-----+-+-+-+-+-+-+
>> |77250|0|0|0|0|0|0|
>> +-----+-+-+-+-+-+-+
>> |77251|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77252|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77253|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77254|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>> |77255|0|0|0|0|0|0|
>> +-----+-+-+-+-+-+-+
>> |77256|0|0|0|0|0|0|
>> +-----+-+-+-+-+-+-+
>> |77257|1|2|3|4|5|6|
>> +-----+-+-+-+-+-+-+
>>
>> I'm stumped as to how to fill in the missing values.  Any assistance
>> would be greatly appreciated!
>>
>>
>> Harvey
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to