Fortran How to Read Specific Data from a Fortran Table File?

Click For Summary
The discussion centers around a beginner in programming with Fortran seeking assistance in reading specific data from a formatted text file. The file contains names, ages, heights, and weights of individuals, and the user wants to extract data for selected names, specifically Luke and Sally. The user has attempted using loops and conditional statements but is struggling to implement a working solution. Suggestions from other participants include sharing code snippets and outlining the steps needed to achieve the desired functionality, such as opening the file, reading lines, and checking for names. The focus is on providing practical coding help and clarifying the process to extract the relevant data.
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 Logical Dog
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
8
Views
2K
  • · 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