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

Home » Public Forums » archive » Create an array for data opend and read from text file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Create an array for data opend and read from text file [message #94164] Thu, 09 February 2017 20:44 Go to previous message
smnadoum is currently offline  smnadoum
Messages: 24
Registered: June 2016
Junior Member
Hi,

I might be over thinking this but I could use some help. I wrote this code that opens and reads data from a text file. I am trying to create an array for the data that was opened, read, and printed, however, my attempts for creating an array for the data are all unsuccessful: mwell=float(x, logx, y) . Can anyone identify the problem?


pro read_text, file, dir

dir='C:\Users\shereen\Videos'
file= 'C:\Users\shereen\Videos\test.txt'

n = file_lines(file)
x= fltarr(n)
y= fltarr(n)
logx= fltarr(n)
x0= 0.0
logx0= 0.0
y0=0.0


openr, iunit, file, /get_lun

for i= 0, n-1 do begin

readf, iunit, x0, logx0, y0

x[i]= x0

logx[i]= logx0

y[i]=[y0]

endfor


free_lun, iunit

for i = 0, n-1 do print, x[i], logx[i], y[i]
;;idl prints
0.115825 0.251150 0.344600
0.0822174 0.266348 0.406000
0.0674909 0.246855 0.531873
0.0985870 0.225174 0.506348
0.117978 0.189022 0.541152
0.119739 0.196804 0.457326
0.137261 0.221652 0.426978
0.128391 0.209696 0.400348
0.132717 0.247109 0.365717
0.103391 0.229152 0.312783
0.122043 0.221109 0.371478
0.0880652 0.277435 0.365022
0.157629 0.179771 0.360571
0.256195 0.256195 0.441024
0.262326 0.262326 0.454457
0.229582 0.229582 0.529491
0.185870 0.185870 0.588435
0.160543 0.160543 0.542522
0.178348 0.178348 0.531804
0.206630 0.206630 0.452717
0.239457 0.239457 0.405826
0.242913 0.242913 0.349891
0.277283 0.277283 0.365630
0.244478 0.244478 0.413913
0.225174 0.225174 0.478543
0.207629 0.207629 0.449314
0.389293 0.245756 0.389293
0.408196 0.222978 0.408196
0.433745 0.245418 0.433745
0.493109 0.219761 0.493109
0.435891 0.227109 0.435891
0.456435 0.257217 0.456435
0.450022 0.231522 0.450022
0.408457 0.235239 0.408457
0.392261 0.212826 0.392261
0.445522 0.261696 0.445522
0.413543 0.234130 0.413543
0.415348 0.217891 0.415348
0.441343 0.210971 0.441343

mwell=float(x, logx, y) ;I want to create an array for the printed data without changing the size, dimension, etc..

end


Thank you.
[Message index]
 
Read Message
Read Message
Previous Topic: IDL installation in mac OS X 10.11
Next Topic: TV type routine that can use irregular x and y coordinates?

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

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

Total time taken to generate the page: 0.00567 seconds