|
|
Re: how can I read many columns and rows [message #92932 is a reply to message #92929] |
Wed, 30 March 2016 02:35   |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
On Tuesday, March 29, 2016 at 7:21:02 PM UTC+1, Ali Gamal wrote:
> Hi everyone,
> I have data file contains 30 column, every column contains 20 row. How can I read this file ?
If all values are of the same type it's trivial:
a = fltarr(30, 20)
OPENR, 1, filename
READF, 1, a
CLOSE, 1
|
|
|
|
|
|
|
Re: how can I read many columns and rows [message #92946 is a reply to message #92945] |
Thu, 31 March 2016 09:39   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Thursday, March 31, 2016 at 10:55:03 AM UTC-4, Ali Gamal wrote:
> On Tuesday, March 29, 2016 at 8:21:02 PM UTC+2, Ali Gamal wrote:
>> Hi everyone,
>> I have data file contains 30 column, every column contains 20 row. How can I read this file ?
>
> I have file data contains many columns, I want to know How can I read this file?, then how can I define each column to use this column in mathematical operations?.
Several previous posters already told you how to read the data into an array.
Once you have an array, arr, then you can, for example, select the 6th column
column5 = arr[5,*]
|
|
|
Re: how can I read many columns and rows [message #92948 is a reply to message #92929] |
Thu, 31 March 2016 10:38   |
Ali Gamal
Messages: 98 Registered: June 2013
|
Member |
|
|
On Tuesday, March 29, 2016 at 8:21:02 PM UTC+2, Ali Gamal wrote:
> Hi everyone,
> I have data file contains 30 column, every column contains 20 row. How can I read this file ?
when I run my IDL program
;;;;;;;;;;;;;;;;;;;;;;;
a = fltarr(6, 50)
OPENR, 1, 'H:\a.dat'
READF, 1, a
CLOSE, 1
column5=a[5,*]
print,column5
end
;;;;;;;;;;;;;;;;;;;;;
it does not print whole column 6 but it print half of column then repeat it as
3910.30
3939.00
3987.40
4052.60
4119.90
4187.30
4255.50
4316.80
4381.10
4448.40
4505.70
4568.90
4624.30
4680.70
4755.30
4846.50
4963.10
5124.50
5308.60
5564.50
6038.90
6617.80
7283.90
8065.40
8500.00
................ it repeat again
3910.30
3939.00
3987.40
4052.60
4119.90
4187.30
4255.50
4316.80
4381.10
4448.40
4505.70
4568.90
4624.30
4680.70
4755.30
4846.50
4963.10
5124.50
5308.60
5564.50
6038.90
6617.80
7283.90
8065.40
8500.00
...........
what is the problem
|
|
|
Re: how can I read many columns and rows [message #92949 is a reply to message #92948] |
Thu, 31 March 2016 11:50   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
I would check your assumptions. For example, you previously told us that your array contained 30 columns, 20 rows. But for some reason you dimension your array fltarr(6,50), which has 300 elements instead of 600. Maybe that is why only half the column is being read?
On Thursday, March 31, 2016 at 1:38:05 PM UTC-4, Ali Gamal wrote:
> On Tuesday, March 29, 2016 at 8:21:02 PM UTC+2, Ali Gamal wrote:
>> Hi everyone,
>> I have data file contains 30 column, every column contains 20 row. How can I read this file ?
>
> when I run my IDL program
> ;;;;;;;;;;;;;;;;;;;;;;;
> a = fltarr(6, 50)
> OPENR, 1, 'H:\a.dat'
> READF, 1, a
> CLOSE, 1
> column5=a[5,*]
> print,column5
> end
> ;;;;;;;;;;;;;;;;;;;;;
> it does not print whole column 6 but it print half of column then repeat it as
> 3910.30
> 3939.00
> 3987.40
> 4052.60
> 4119.90
> 4187.30
> 4255.50
> 4316.80
> 4381.10
> 4448.40
> 4505.70
> 4568.90
> 4624.30
> 4680.70
> 4755.30
> 4846.50
> 4963.10
> 5124.50
> 5308.60
> 5564.50
> 6038.90
> 6617.80
> 7283.90
> 8065.40
> 8500.00
> ................ it repeat again
> 3910.30
> 3939.00
> 3987.40
> 4052.60
> 4119.90
> 4187.30
> 4255.50
> 4316.80
> 4381.10
> 4448.40
> 4505.70
> 4568.90
> 4624.30
> 4680.70
> 4755.30
> 4846.50
> 4963.10
> 5124.50
> 5308.60
> 5564.50
> 6038.90
> 6617.80
> 7283.90
> 8065.40
> 8500.00
> ...........
> what is the problem
|
|
|
|
Re: how can I read many columns and rows [message #92951 is a reply to message #92950] |
Thu, 31 March 2016 13:29   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
On 03/31/16 15:50, Ali Gamal wrote:
> On Tuesday, March 29, 2016 at 8:21:02 PM UTC+2, Ali Gamal wrote:
>> Hi everyone,
>> I have data file contains 30 column, every column contains 20 row.
>> How can I read this file ?
>
> I change dimension to array fltarr(6,50) for test only. It is another
> file. my new file is 6 columns and every column contains 50 row. I guess
> this problem because my data as this form
>
> 1.402E+00 3.700E-01 1.443E+00
> 1.403E+00 3.711E-01 1.443E+00
[snip]
> 9.932E-01 9.921E-01 9.917E-01
> 9.928E-01 9.918E-01 9.915E-01
> 9.948E-01 9.942E-01 9.941E-01
> 9.966E-01 9.963E-01 9.962E-01
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> I guess my program take column 1 and column 4 as one column. what is
> the true way to do it?
>
I couldn't find any primers online at Harris but you could have a look
at: http://www.harrisgeospatial.com/docs/idl_programming.html
Or, for reasonably priced books:
http://www.amazon.com/Practical-IDL-Programming-Liam-Gumley/ dp/1558607005
or
http://www.idlcoyote.com/coyotestore/index.php?main_page=pro duct_info&cPath=66&products_id=183
Please understand I'm not trying to be mean spirited here - I really
think you would benefit from some reading material about IDL programming.
cheers,
paulv
|
|
|
|