comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Making an array of only the first number of each row in a file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Making an array of only the first number of each row in a file [message #92434] Mon, 14 December 2015 22:12 Go to next message
tryanguy is currently offline  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 Go to previous message
Nikola is currently offline  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, *])
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Writing PNG file in pure IDL with metadata
Next Topic: Google search from within an IDL program

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:19:15 PDT 2025

Total time taken to generate the page: 0.00481 seconds