i'm new to dyalog APL and i'm struggling to read some input from an .txt file under Windows 10.
The input data has the format: number name newline
I want to store every line as an array element and in theory the input←⎕NGET 'input.txt' 1
function i'm using should work just fine.
According to the docs I should get a vector of char vectors as a result. But in my case I just get a scalar.
I'm able to transform the scalar into a vector of chars with ⍕input[1]
but then i have every line in one single vector which is the oposite of what input←⎕NGET 'input.txt' 1
should have given me.
Did i miss a page or why is the initial function not working as it should do?
Thank you very much for your help!
Asked
Active
Viewed 537 times
2

erbsenhexler
- 27
- 6
1 Answers
3
As per the docs:
The result R is a 3-element vector comprising
(content) (encoding) (newline)
You're only interested in the first element, so the First function (⊃
) is your friend:
input←⊃⎕NGET 'input.txt' 1

Adám
- 6,573
- 20
- 37
-
Thank you! But now i'm confused. When ⊃ gives you the first element of a vector and indexing like in C input[1] is also possible, why do i get a nested array if i use ⊃input but only a giant scalar if i use input[1]? – erbsenhexler Dec 07 '21 at 13:25
-
@erbsenhexler Does [this](https://stackoverflow.com/a/46834334/5306507) answer your question? – Adám Dec 07 '21 at 13:42
-
yes it does. Thank you again – erbsenhexler Dec 07 '21 at 14:36