Hi all,
Small problem or newbie trap? After loading a table using 'tables/csv' (or
tables/dsv' - doesn't matter), I noticed that single characters are not
being matched using the below approach. (J version 9.4) on Ubuntu Linux
22.04.
Is there some hidden character that causes the match to fail? Is it a
character set issue? What am I missing?
Best regards,
Dimitri Georganas
Biodys BV
The Netherlands
data=: readcsv'/home/dg/dev/za2.txt'
data
┌─┬─┬─┬─┬─┐
│1│2│3│b│4│
├─┼─┼─┼─┼─┤
│1│2│3│c│4│
└─┴─┴─┴─┴─┘
control =: ('1';'2';'3';'b';'4')
control =: control,:control
control
┌─┬─┬─┬─┬─┐
│1│2│3│b│4│
├─┼─┼─┼─┼─┤
│1│2│3│b│4│
└─┴─┴─┴─┴─┘
] control =: (<'c') (<1 3) } control
┌─┬─┬─┬─┬─┐
│1│2│3│b│4│
├─┼─┼─┼─┼─┤
│1│2│3│c│4│
└─┴─┴─┴─┴─┘
$data
2 5
$control
2 5
(<'c') = control
0 0 0 0 0
0 0 0 1 0
(<'c') = data
0 0 0 0 0
0 0 0 0 0
data =: (<'p') (< 1 3) } data
data
┌─┬─┬─┬─┬─┐
│1│2│3│b│4│
├─┼─┼─┼─┼─┤
│1│2│3│p│4│
└─┴─┴─┴─┴─┘
(<'p') = data
0 0 0 0 0
0 0 0 1 0
(<'b') = data
0 0 0 0 0
0 0 0 0 0
NB. Section bypassing 'tables/csv'
rawdata =: fread'/home/dg/dev/za2.txt'
rawdata
1,2,3,b,4
1,2,3,c,4
'b' = rawdata
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
cutLF rawdata
┌─────────┬─────────┐
│1,2,3,b,4│1,2,3,c,4│
└─────────┴─────────┘
',' cut each cutLF rawdata
┌───────────┬───────────┐
│┌─┬─┬─┬─┬─┐│┌─┬─┬─┬─┬─┐│
││1│2│3│b│4│││1│2│3│c│4││
│└─┴─┴─┴─┴─┘│└─┴─┴─┴─┴─┘│
└───────────┴───────────┘
>',' cut each cutLF rawdata NB. there's probably a more elegant way :)
┌─┬─┬─┬─┬─┐
│1│2│3│b│4│
├─┼─┼─┼─┼─┤
│1│2│3│c│4│
└─┴─┴─┴─┴─┘
(<'c') = >',' cut each cutLF rawdata
0 0 0 0 0
0 0 0 0 0
(<'Q') (< 1 3) } >',' cut each cutLF rawdata
┌─┬─┬─┬─┬─┐
│1│2│3│b│4│
├─┼─┼─┼─┼─┤
│1│2│3│Q│4│
└─┴─┴─┴─┴─┘
(<'Q') = (<'Q') (< 1 3) } >',' cut each cutLF rawdata
0 0 0 0 0
0 0 0 *1* 0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm