Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Read Data from txt

stutzbach
Beginner
539 Views

Hello,

saving a file in excel as unicode text (*.txt). Is there an oppurtunity to read just one special column in a special row?
Perhaps someone could post an example code.I am trying for ours with deskriptors ... without success

maybe an example:

1234.00 2134.00 14.000
123.00 123.12 2343.00

how would the code look like for reading in 123.12?

READ(unit, 100)
100 Format (????)

Greeting Stutzbach

0 Kudos
3 Replies
mecej4
Honored Contributor III
539 Views
Assuming that the input file contains only numbers separated by blanks, and that every line contains the same number of entries,

real :: X,DUM
integer, irow = 2, jcol=2, ncol=3

open(unit,...,ENCODING='utf-8')
..
do i=1, irow-1
read(unit,*) ! rows 1.. (irow-1) skipped
end do
read(unit,*)((DUM,j=1,jcol-1), X) ! special value in row=irow, col=jcol
..

The value in the irow-th row and the jrow-th column will be in the variable X.

Unless you want to process implicit decimal points, etc., list-directed I/O is sufficient to do the job.

0 Kudos
anishtain4
Beginner
539 Views
is there anyway to read a number of data that you don't know how much of them are in a row?
for example in unstructured grid there could be a mixes form of grids where there are triangle and squar elements, you don't know which element has 3 side and which has 4?
for example data are like:
3 4 10
20 11 30 12
8 5 2
19 13 29
21 9 2
......

however numbers in a row may differ but there is a maximum number of digits that can be in a row, for example they won't exceed N which will be determined somewhere else, how do you read this?
0 Kudos
anishtain4
Beginner
539 Views
Thanks, it helped a lot
0 Kudos
Reply