Making an array of only the first number of each row in a file [message #92434] |
Mon, 14 December 2015 22:12  |
tryanguy
Messages: 1 Registered: December 2015
|
Junior Member |
|
|
Hi all, I'm having trouble making an array consisting of only the first number of each row in a file. Here is an example of one of the rows: 13 1:0.440091 2:0.663382 3:0.871638 4:0.896678 5:0.834448
I just want to take the first number, 13, and put it into an array along with all the other first numbers in each row.
What I've attempted so far:
arr1 = make_array(1,500)
openr, 1, 'filelocation'
readf, 1, arr1
This forms an array consisting of (13,1,2,3,5,...). How do I ignore the subsequent numbers in each row?
Thanks for your consideration
-Tim
|
|
|
Re: Making an array of only the first number of each row in a file [message #92435 is a reply to message #92434] |
Tue, 15 December 2015 02:22  |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
arr = FLTARR(n)
a = 0.
OPENR, 1, filename
FOR i = 0, n-1 DO BEGIN
READF, 1, a
arr[i] = a
ENDFOR
CLOSE, 1
or
a = FLTARR(n, ncolumns)
OPENR, 1, filename
READF, 1, a
CLOSE, 1
arr = REFORM(a[0, *])
|
|
|