read a multi-line string in IDL? or, read numeric values sequentially without automatic <CR>? [message #87407] |
Fri, 31 January 2014 11:00  |
pcoelho.astro
Messages: 1 Registered: January 2014
|
Junior Member |
|
|
hello everyone,
here is the problem. I need to read numeric values from an ASC file which doesn't have any predefined format. The only thing I know is the number of values I'm supposed to read. FORTRAN will read it as:
READ(12,*) (NV(J),J=1,NUMBER)
(the ASC file is like that because it is used by an old FORTRAN code)
The values can be in a multi-line string or not (example below). READF will read one number per line only. Read the whole line as a string and use STRSPLIT doesn't work because the whole data set might be multi-line. The number of values per line may also change (the format also).
Messy I know. Any tip or tricks?
many thx
Paula
For example, I need to read 197 than 33 numbers from a file like below:
0.00 2042.39 4058.52 6048.34 8011.79 9948.83 0.00 2042.39 4058.52 6048.34
8011.79 9948.83 11859.39 0.00 2042.39 4058.52 6048.34 8011.79 9948.83 11859.39
13743.42 0.00 2042.39 4058.52 6048.34 8011.79 9948.83 11859.39 13743.42 15600.88
2042.39 4058.52 6048.34 8011.79 9948.83 11859.39 13743.42 15600.88 17431.69 4058.52
6048.34 8011.79 9948.83 11859.39 13743.42 15600.88 17431.69 19235.81 21013.18 6048.34
8011.79 9948.83 11859.39 13743.42 15600.88 17431.69 19235.81 21013.18 22763.76 8011.79
9948.83 11859.39 13743.42 15600.88 17431.69 19235.81 21013.18 22763.76 24487.47 9948.83
11859.39 13743.42 15600.88 17431.69 19235.81 21013.18 22763.76 24487.47 26184.28 9948.83
11859.39 13743.42 15600.88 17431.69 19235.81 21013.18 22763.76 24487.47 26184.28 27854.12
11859.39 13743.42 15600.88 17431.69 19235.81 21013.18 22763.76 24487.47 26184.28 27854.12
29496.95 13743.42 15600.88 17431.69 19235.81 21013.18 22763.76 24487.47 26184.28 27854.12
29496.95 15600.88 17431.69 19235.81 21013.18 22763.76 24487.47 26184.28 27854.12 29496.95
31112.70 32701.31 17431.69 19235.81 21013.18 22763.76 24487.47 26184.28 27854.12 29496.95
31112.70 32701.31 34262.75 19235.81 21013.18 22763.76 24487.47 26184.28 27854.12 29496.95
31112.70 32701.31 34262.75 35796.95 19235.81 21013.18 22763.76 24487.47 26184.28 27854.12
29496.95 31112.70 32701.31 34262.75 35796.95 21013.18 22763.76 24487.47 26184.28 27854.12
29496.95 31112.70 32701.31 34262.75 35796.95 22763.76 24487.47 26184.28 27854.12 29496.95
31112.70 32701.31 34262.75 35796.95 24487.47 26184.28 27854.12 29496.95 31112.70 32701.31
34262.75 35796.95 24487.47 26184.28 27854.12 29496.95 31112.70 32701.31 34262.75 35796.95
26184.28 27854.12 29496.95 31112.70 32701.31 34262.75 35796.95
1.14E-03 3.85E-03 7.85E-04 8.55E-03 3.66E-02 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.
|
|
|