Search code examples
fortranfortran95

How to read a specific column out of matrix-textfile? without reading whole line?


I have a textfile including thousends of lines and each line have 899 values/columns separated by ';' (but i can change the seperation if needed)

Is there a way to read a defined column (i want to tell the code which (per read icolumn)) without reading the whole line into variables?

So what I know: read(unit,*) a,b,c,d,e,... (899 times is not cool) otherwise I would put all this values in an array. And after I could read my column with: array(i,icolumn)

I would like a direct way.


Solution

  • If you know the number is at character 165 then you just use the t or tr or x descriptor to move there and read the number

    read(unit,'(t165,f12.0)' array(whatever)
    

    if you need to put the number 165 into the format string you can use this function.