Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read free-formatted data in text file

Status
Not open for further replies.

bklee

Programmer
Jul 29, 2003
3
KR
How can I read the free-formatted data in text file?
I want to know the logics to find which columns have the target data no matter how many columns a row has.
 
Please explain free formatted
1) Any number of items in a row
2) A known number of items but in unknown positions

(1) requires a bit of thinking.
(2) use read (10,*) a, b, c

If you don't know how many items there are, read it into a characater string first,
Code:
character*80 str
read(10,'(A80)') str
scan the string to count how many. Say there are n items
Code:
read (str, *) (x(i), i = 1, n, 1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top