> ". does not seem to be an option…

It is an option if you first convert '/' to ';'.
Or better still, I think, if you convert '/' and ';' to ' '.

   y=: '1;2242;22/11/2018;39.70;'

   ]indexes=: I. y e. ';/'
1 6 9 12 17 23
   ]z=: ' ' indexes } y
1 2242 22 11 2018 39.70
   'a b day month year value'=: ".z

   a
1
   b
2242
   day
22
   month
11
   year
2018
   value
39.7

Substitute for intermediates to package it all up into an explicit verb:

   chomp=: 3 : 0
". ' ' (I. y e. ';/') } y
)
   chomp  NB. as a 1-liner
3 : '". '' '' (I. y e. '';/'') } y'
   chomp y
1 2242 22 11 2018 39.7

On Sat, 1 Dec 2018 at 00:15, Rúben Cabaço <[email protected]> wrote:

> What is the best way to convert bytes of numbers and dates to appropriate
> values?
>
> The data I am trying to convert is in the following format:
> 1;2242;22/11/2018;39.70;
>
> I have managed to read it, but am stumbling in the conversion part. Using
> ". does not seem to be an option since I get a domain error on the date,
> which makes sense.
>
> Perhaps I should be trying to apply ". on those values that are appropriate
> and some other primitive on the date. How would I do this?
>
> Thanks,
> Rúben
> ----------------------------------------------------------------------
> 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