<@;@(1&{ , '-' ; 0&{ , '/' ; 3&{)"1 q will get you a boxed list. You can flatten that with ; or add CRLF as needed.
Henry Rich On 8/9/2011 6:07 PM, PackRat wrote: > Here is some sample stock data: > > s1=. 'JCI';'Johnson Controls';'700';'197412020000' > s2=. 'JNPR';'Juniper Networks';'440';'200910290930' > s3=. 'K';'Kellogg Co';'315';'195905120000' > s4=. 'KSS';'Kohl"s Corp';'250';'199205190000' > s5=. 'PHG';'Koninklijke Philips Electronics';'920';'198704140000' > s6=. 'KFT';'Kraft Foods';'1750';'200106130945' > s7=. 'LSI';'LSI Corp';'600';'198910020000' > s8=. 'LF';'LeapFrog Enterprises';'66';'200207250950' > s9=. 'LEG';'Leggett& Platt';'140';'197906250000' > > q=. 9 4 $ (s1,s2,s3,s4,s5,s6,s7,s8,s9) > > +----+-------------------------------+----+------------+ > |JCI |Johnson Controls |700 |197412020000| > +----+-------------------------------+----+------------+ > |JNPR|Juniper Networks |440 |200910290930| > +----+-------------------------------+----+------------+ > |K |Kellogg Co |315 |195905120000| > +----+-------------------------------+----+------------+ > |KSS |Kohl"s Corp |250 |199205190000| > +----+-------------------------------+----+------------+ > |PHG |Koninklijke Philips Electronics|920 |198704140000| > +----+-------------------------------+----+------------+ > |KFT |Kraft Foods |1750|200106130945| > +----+-------------------------------+----+------------+ > |LSI |LSI Corp |600 |198910020000| > +----+-------------------------------+----+------------+ > |LF |LeapFrog Enterprises |66 |200207250950| > +----+-------------------------------+----+------------+ > |LEG |Leggett& Platt |140 |197906250000| > +----+-------------------------------+----+------------+ > > In the real world, q is an array of data read in from a CSV file. > Next, I did this (there may be better ways, but this worked for me): > > q2=. |: q > tsdatax=. ((>1{q2),.'-'),.((>0{q2),.'/'),.(>3{q2) > > And this is what the result (tsdatax) looks like (49-char literals): > > Johnson Controls -JCI /197412020000 > Juniper Networks -JNPR/200910290930 > Kellogg Co -K /195905120000 > Kohl's Corp -KSS /199205190000 > Koninklijke Philips Electronics-PHG /198704140000 > Kraft Foods -KFT /200106130945 > LSI Corp -LSI /198910020000 > LeapFrog Enterprises -LF /200207250950 > Leggett& Platt -LEG /197906250000 > > All nice and good, but now how do I get rid of the space fill > characters that padded out the original cells so that I can write out > each of these 49-char literals as ragged literals as follows: > > Johnson Controls-JCI/197412020000 > Juniper Networks-JNPR/200910290930 > Kellogg Co-K/195905120000 > Kohl's Corp-KSS/199205190000 > Koninklijke Philips Electronics-PHG/198704140000 > Kraft Foods-KFT/200106130945 > LSI Corp-LSI/198910020000 > LeapFrog Enterprises-LF/200207250950 > Leggett& Platt-LEG/197906250000 > > Please note that I'm NOT trying to get rid of ALL spaces--only the > spaces that had been originally added as padding to initially produce > same-sized cells in the original array. > > Thanks in advance for any assistance! > > > 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