A couple of points:

You could replace ( (-.y='"')#y ) with ( y -. '"' )

If you use dyadic ". to convert character representations of numbers
to numbers, then it will handle converting '-' to negative numbers -
no need to do it manually.
   _99 ". '-3.43 54 -2 0.4'
_3.43 54 _2 0.4

The ( makenumcol ) from the tables/dsv addon may be of interest.

makenumcol (v) Converts columns in table of boxed literals to numeric
where possible
form: [err] makenumcol array
returns: numeric array or array of boxed literal and numeric columns
y is: an array of boxed literals
x is: optional numeric error code. Default is _9999
Only converts column to numeric if conversion is possible for whole column

Regards,
Ric

On Thu, Jan 12, 2012 at 9:13 AM, Tom Szczesny <[email protected]> wrote:
> Thanks, that is very nice to know, but ...
>
> Since the csv files I need were created by me, I also know that
> -  the only occurrences of   "   are spuriously added.
> -  the only occurrences of   -   are in the representation of negative
> numbers, so I can define
>
> tblcsv=: 3 : 0
>   r=: (-.y='"')#y
>   r=: '_' ((r='-')#i.$r) } r
>   ([: < ;._1 ',',]) ;._2 r
> )
>
> Next, I plan to figure out how to convert the columns with character
> strings representing numbers into actual numbers,
> and the columns with character strings representing dates ( 2012/01/12 )
> into numbers representing dates ( 20120112 ),
> where tblcsv becomes dyadic with a control vector like 'SDSSNDNSNS' as the
> left argument
> indicating which columns are strings, dates & numbers.
>
> On Wed, Jan 11, 2012 at 2:27 PM, Ric Sherlock <[email protected]> wrote:
>
>> Note that you don't need to define tblcsv explicitly:
>>   tblcsv=: ([: <;._1 ','&,);._2
>> or
>>   tblcsv=: ([: <;._1 ',' , ]);._2
>>
>> On Thu, Jan 12, 2012 at 6:29 AM, Tom Szczesny <[email protected]> wrote:
>> > tested  ......  works . .....  thanks!
>> >
>> > On Wed, Jan 11, 2012 at 12:23 PM, R.E. Boss <[email protected]> wrote:
>> >
>> >> tblcsv =: 3 : 0
>> >>  ([: <;._1 ',',]) ;._2 y
>> >>  )
>> >> (untested)
>> >>
>> >> R.E. Boss
>> >>
>> >>
>> >> > -----Oorspronkelijk bericht-----
>> >> > Van: [email protected] [mailto:general-
>> >> > [email protected]] Namens Tom Szczesny
>> >> > Verzonden: woensdag 11 januari 2012 17:55
>> >> > Aan: General forum
>> >> > Onderwerp: Re: [Jgeneral] Data from csv files
>> >> >
>> >> > Given
>> >> >
>> >> > cutc =: 3 : 0
>> >> >   < ;._1 ',',y
>> >> > )
>> >> >
>> >> > tblcsv =: 3 : 0
>> >> >   cutc ;._2 y
>> >> > )
>> >> >
>> >> > tblcsv 1!:1 <'test.csv'
>> >> >
>> >> > I assumed that I would be able to represent this as a single
>> definition,
>> >> > such as
>> >> >
>> >> > tblcsv =: 3 : 0
>> >> >   ( <;._1 ',',) ;._2 y
>> >> > )
>> >> >
>> >> > or
>> >> >
>> >> > tblcsv =: 3 : 0
>> >> >   (( <;._1',',)&) ;._2 y
>> >> > )
>> >> >
>> >> > I've tried several other vaiations, and all result in 'syntax error'.
>>  Am
>> >> I
>> >> > missing something, or does the verb applied to each 'cut' interval
>> need
>> >> to
>> >> > be defined separately?
>> >> >
>> >> > On Mon, Jan 9, 2012 at 5:00 PM, Arthur Anger <[email protected]> wrote:
>> >> >
>> >> > > I often use Rank to select sub-arrays from an array:
>> >> > >  <"0 i. 7
>> >> > > --Art
>> >> > > ------------------
>> >> > > Quoting [email protected]:
>> >> > > . . .
>> >> > > > Message: 2
>> >> > > > Date: Mon, 9 Jan 2012 11:46:24 -0500
>> >> > > > From: Tom Szczesny <[email protected]>
>> >> > > > Subject: Re: [Jgeneral] Data from csv files
>> >> > > > To: General forum <[email protected]>
>> >> > > > Message-ID:
>> >> > > >       <CABn7SNYFw2gyAPKcjx1DMLEru97NMTst6zoGx=
>> >> > > [email protected]>
>> >> > > > Content-Type: text/plain; charset=ISO-8859-1
>> >> > > >
>> >> > > > As mentioned in the dictionary entry for cut:
>> >> > > > the phrase   u;._2 y     applies the verb u to each interval
>> created
>> >> by
>> >> > > cut,
>> >> > > > where the fret is the last item, and marks the ends of the
>> intervals.
>> >> > > >
>> >> > > > What is the notation for applying the "each" concept to a verb
>> >> > > independent
>> >> > > > of   cut   ?
>> >> > > > For example,
>> >> > > >   <i.7
>> >> > > > +-------------+
>> >> > > > |0 1 2 3 4 5 6|
>> >> > > > +-------------+
>> >> > > >
>> >> > > > How do you express
>> >> > > >    <  each  i.7
>> >> > > > and get 7 individually boxed items?
>> >> > > > (I could not find an entry for "each" in the Index, nor in the
>> >> > > Vocabulary.)
>> >> > > . . .
>> >> > > > End of General Digest, Vol 76, Issue 8
>> >> > > > **************************************
>> >> > >
>> >> > >
>> ----------------------------------------------------------------------
>> >> > > For information about J forums see
>> >> > http://www.jsoftware.com/forums.htm
>> >> > >
>> >> > ----------------------------------------------------------------------
>> >> > For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> >>
>> >> ----------------------------------------------------------------------
>> >> For information about J forums see http://www.jsoftware.com/forums.htm
>> >>
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> 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