- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Sir/Madam:
How are you?
Now I have a problem about Fortran.
I have a file, it contains the data I need, but also have some
not used data, and each row have different data format,
I don't know how to 'read' this kind of free file to obtain
the data I want. (Because in the past, the files I want to
read are all in certain format, and I can read it easily)
For example: the file is like following:
I only want to read the red part in my program to get
the datatI needand other data have no use.
How can I do it? If you know, please give me some advice.
Thanks very much!
CRPLIM, 0.100000000 , 0
CRPLIM, 0.00000000 , 1
NCNV, 1, 0.00000000 , 0, 0.00000000 , 0.00000000
CRPLIM, 0.00000000 , 1
NCNV, 1, 0.00000000 , 0, 0.00000000 , 0.00000000
NEQIT, 0
ERESX,DEFA
ACEL, 0.00000000 , 0.00000000 , 0.00000000
OMEGA, 0.00000000 , 0.00000000 , 0.00000000 , 0
DOMEGA, 0.00000000 , 0.00000000 , 0.00000000
CGLOC, 0.00000000 , 0.00000000 , 0.00000000
CGOMEGA, 0.00000000 , 0.00000000 , 0.00000000
DCGOMG, 0.00000000 , 0.00000000 , 0.00000000
IRLF, 0
ACEL, 0.00000000 , 0.00000000 , 0.00000000
OMEGA, 0.00000000 , 0.00000000 , 0.00000000 , 0
DOMEGA, 0.00000000 , 0.00000000 , 0.00000000
CGLOC, 0.00000000 , 0.00000000 , 0.00000000
CGOMEGA, 0.00000000 , 0.00000000 , 0.00000000
DCGOMG, 0.00000000 , 0.00000000 , 0.00000000
IRLF, 0
D, 2,UX , 0.00000000 , 0.00000000
D, 11,UX , 0.00000000 , 0.00000000
D, 13,UX , 0.00000000 , 0.00000000
D, 14,UX , 0.00000000 , 0.00000000
D, 15,UX , 0.00000000 , 0.00000000
D, 16,UX , 0.00000000 , 0.00000000
D, 17,UX , 0.00000000 , 0.00000000
D, 18,UX , 0.00000000 , 0.00000000
D, 29,UX , 0.00000000 , 0.00000000
D, 31,UX , 0.00000000 , 0.00000000
D, 32,UX , 0.00000000 , 0.00000000
D, 33,UX , 0.00000000 , 0.00000000
D, 41,UX , 0.00000000 , 0.00000000
D, 43,UX , 0.00000000 , 0.00000000
D, 44,UX , 0.00000000 , 0.00000000
D, 45,UX , 0.00000000 , 0.00000000
D, 57,UX , 0.00000000 , 0.00000000
D, 59,UX , 0.00000000 , 0.00000000
D, 60,UX , 0.00000000 , 0.00000000
D, 61,UX , 0.00000000 , 0.00000000
D, 62,UX , 0.00000000 , 0.00000000
D, 63,UX , 0.00000000 , 0.00000000
D, 64,UX , 0.00000000 , 0.00000000
D, 65,UX , 0.00000000 , 0.00000000
D, 76,UX , 0.00000000 , 0.00000000
D, 78,UX , 0.00000000 , 0.00000000
D, 79,UX , 0.00000000 , 0.00000000
/GOPR
D, 11,UX , 0.00000000 , 0.00000000
D, 13,UX , 0.00000000 , 0.00000000
D, 14,UX , 0.00000000 , 0.00000000
D, 15,UX , 0.00000000 , 0.00000000
D, 16,UX , 0.00000000 , 0.00000000
D, 17,UX , 0.00000000 , 0.00000000
D, 18,UX , 0.00000000 , 0.00000000
D, 29,UX , 0.00000000 , 0.00000000
D, 31,UX , 0.00000000 , 0.00000000
D, 32,UX , 0.00000000 , 0.00000000
D, 33,UX , 0.00000000 , 0.00000000
D, 41,UX , 0.00000000 , 0.00000000
D, 43,UX , 0.00000000 , 0.00000000
D, 44,UX , 0.00000000 , 0.00000000
D, 45,UX , 0.00000000 , 0.00000000
D, 57,UX , 0.00000000 , 0.00000000
D, 59,UX , 0.00000000 , 0.00000000
D, 60,UX , 0.00000000 , 0.00000000
D, 61,UX , 0.00000000 , 0.00000000
D, 62,UX , 0.00000000 , 0.00000000
D, 63,UX , 0.00000000 , 0.00000000
D, 64,UX , 0.00000000 , 0.00000000
D, 65,UX , 0.00000000 , 0.00000000
D, 76,UX , 0.00000000 , 0.00000000
D, 78,UX , 0.00000000 , 0.00000000
D, 79,UX , 0.00000000 , 0.00000000
/GOPR
Yours Sincerely:
Nanhui
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Your question is unspecific. "Reading the red part of a file" is no term easily to translate into a program.
Is the part of interest everything with a "D" in the first column? Is it always the part of the file beyond line 13?
Is it every line with 5 string columns having the format "string, data, string, data, data"?
Is the section of interest guaranteed to have columns with fixed length? Will the section of interest always contain 5 Columns? Is it possible that some values have been omitted?
Without knowing this any solution would break with your next datafile.
Your question is unspecific. "Reading the red part of a file" is no term easily to translate into a program.
Is the part of interest everything with a "D" in the first column? Is it always the part of the file beyond line 13?
Is it every line with 5 string columns having the format "string, data, string, data, data"?
Is the section of interest guaranteed to have columns with fixed length? Will the section of interest always contain 5 Columns? Is it possible that some values have been omitted?
Without knowing this any solution would break with your next datafile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The red lines all appear to be the same format.
I would read each record into a character string
with either an unformatted read or using an A
format specifier, checking the beginning of the
"read in" string for "D, ". When it matches,
you can then use a formatted internal read to
retrieve the information from each record and
process it.
I would read each record into a character string
with either an unformatted read or using an A
format specifier, checking the beginning of the
"read in" string for "D, ". When it matches,
you can then use a formatted internal read to
retrieve the information from each record and
process it.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page