[Jprogramming] Minus sign when using writecsv

teatherk at intonet.co.uk teatherk at intonet.co.uk
Thu Feb 16 08:41:16 HKT 2006


Dear all,
I find the low-slung J minus sign a nuisance outside J, as I imagine do other

    J users, and would like to have a conversion from'_' to '-' built into writecsv

    in some future release.
     For the present, I apply the following script to a boxed 'characterised'
table
     that is ready to be submitted to writecsv:
    csvminus =:3 : 0 NB. Replaces negative '_' with '-' within an individually
boxed
    shape=.$y.       NB. "characterized" table prepared for output by writecsv

    numbers=.'0123456789_.abdejprx' 
    listboxes=.,y.
    new=.0$0
    while.0<#listboxes
      do. current=.>{.listboxes
          listboxes=.}.listboxes
          new=.new,<current
          if. -.(*./current e.numbers) 
               do. continue
               elseif. '_'={.current
                       do. new=.(}:new),<'-',}.current
          end.
      end.
    shape $ new
    )

    If anyone can do this more elegantly, I would be happy to follow their lead

    but would add that mine works for 4-dimensional output tables, which I need

    quite often.
C J Teather



More information about the Programming mailing list