I have CSV files with numeric data and I would like to perform analysis on this data. I am hoping that using APL will give me more flexibility than reading this into mysql and performing selects. But to start with I would like to do simple extractions like 'select * from mydata where col1 = 2020'. So far I understand I can use Compress. But for that I need to know the expression that would yield the boolean array for the left argument of compress (i.e. the APL version of 'where col1 = 2020'). Online searches did not get me anywhere in that department.
Asked
Active
Viewed 111 times
2
-
You can get higher quality answers if you specify which implementation and version of APL you use. – Adám Nov 23 '21 at 08:19
-
Ah, yes, sorry about that and thanks for the quick response. I'm using Dyalog 18. – Rudi Angela Nov 23 '21 at 08:55
-
I've added a section about utilising Dyalog APL features. – Adám Nov 23 '21 at 09:14
1 Answers
1
You are indeed right in your speculations.
"col1 = 2020" would be mydata[;1] = 2020
so the entire thing is (mydata[;1] = 2020) ⌿ mydata
My father liked to define
∇ data ← data where condition
data ← condition⌿data
∇
so he could write things like data where data[;1] = 2020
Utilising Dyalog APL features
Dyalog APL provides some notational niceties:
- The inline expression can be written as
mydata ⌿⍨ mydata[;1] = 2020
- The above definition of
where
can be written simply aswhere ← ⌿⍨

Adám
- 6,573
- 20
- 37
-
I see. Nice! Curious: is there a way to avoid repeating the mydata reference? – Rudi Angela Nov 23 '21 at 12:49
-
@RudiAngela There are many variations possible, especially if you begin defining operators. E.g. `select ← {⍵ ⌿⍨ ⍺⍺ ⍵} ⋄ col ← ⌷⍤1⍨` allows you to write `(2020=col∘1)select mydata` or you could define `col ← {⍵ ⌿⍨ ⍺ ⍺⍺ ⍵[;⍵⍵]} ⋄ in←⊢` and write `2020 = col 1 in mydata` – Adám Nov 23 '21 at 13:00
-
-