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

Home » Public Forums » archive » Read data in more than one column
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Read data in more than one column [message #91723 is a reply to message #91717] Fri, 14 August 2015 08:46 Go to previous message
zacharyanorman is currently offline  zacharyanorman
Messages: 17
Registered: July 2015
Junior Member
If you have a text file where all of your data is separated by spaces and each line has the exact same number of data entries, you could try something like this code, which reads the text file and uses STRSPLIT to extract each separate element that has a space between it:

;read the file into a string array which is info
file = 'C:\path\to\file'
OPENR, lun, file, /GET_LUN
nlines = FILE_LINES(file)
info = STRARR(nlines)
READF, lun, info
FREE_LUN, lun

;initialize array of split data
split_info = strarr(n_elements(strsplit(info[0], ' ', /extract)), nlines)
;separate your data by the space that is between them
for i=0, nlines-1 do split_info[i] = strsplit(info,' ' , /extract)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Rant about axis range defaults using overplot in object graphics
Next Topic: Re: Read data in more than one column

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

Current Time: Wed Oct 08 15:52:58 PDT 2025

Total time taken to generate the page: 0.00433 seconds