How to Read Specific Data from a Fortran Table File?

Click For Summary
SUMMARY

This discussion focuses on reading specific data from a Fortran table file, particularly extracting age, height, and weight for specified individuals. The user seeks assistance in implementing this functionality using Fortran programming. Key steps include opening the file, reading lines, and using conditional statements to filter data based on user input. The conversation emphasizes the importance of structured code and logical flow in achieving the desired outcome.

PREREQUISITES
  • Basic understanding of Fortran programming
  • Familiarity with file I/O operations in Fortran
  • Knowledge of conditional statements and loops in programming
  • Experience with data structures for organizing information
NEXT STEPS
  • Learn how to implement file reading in Fortran using the OPEN and READ statements
  • Study the use of DO loops and IF statements in Fortran for conditional data processing
  • Explore how to create and manipulate arrays in Fortran for storing data
  • Investigate best practices for debugging Fortran code to troubleshoot issues effectively
USEFUL FOR

Beginner programmers, Fortran developers, and anyone interested in data manipulation and file processing in Fortran.

Arez
Messages
1
Reaction score
0
Hello
I am very new to programming and fortran. I have a text file formatted the following way:

Name Peter John Sally Joseph Luke Vader etc...
age XXXX XXXX XXXX XXXX XXXX XXXX XXXX
height XXXX XXXX XXXX XXXX XXXX XXXX XXXX
weigh XXXX XXXX XXXX XXXX XXXX XXXX XXXX
etc...​

I want fortran to only read the data of the people I ask him to. If I ask for Luke and Sally, I want him to return their respective age, height and weight while assigning them to specific variables.

I have played around with various do loops with if statements but I can't get it to work properly... I don't know how to do this. Can anyone help ?

Thank you
 
Last edited:
Technology news on Phys.org
It would help if you showed what you have attempted so far. Please use the code tags for your code also.
 
You could also provide the steps you think need to be done in plain english to accomplish the task.

Code:
0 ask for names you want to report on
1 open file
2 read line
3 if line starts with name ...
 
  • Like
Likes   Reactions: Logical Dog

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K