0
I’m a layman, still taking the first steps in programming and C# and I’m having trouble solving a problem.
I would like to search a specific information in a txt file with the following lines:
Nodal force point
15 25 30
20 35 13
25 85 25
Nodal Moment point
23 58 6
6 4 5
3 2 1
Nodal displacements point
25 1 5
2 5 4
6 4 5
Well, I need to identify the "Nodal Moment point" and store the second row value (In that case, the 4).
Note: It will not necessarily be 4, since they are randomly generated values. Ah, the file will always follow this pattern (Each title will have 3 rows of data, it will always have a blank row and the columns are separated by 2 spaces)
I am using the following code to locate the part of the file that contains the "Nodal Moment point":
var valor = File.ReadAllLines("NomeDoArquivo.txt")
.Where(l=>l.StartsWith("Nodal Moment"))
However, I don’t know how to find the second value of the second line and store in the variable.
I thank you in advance for your help.
There is no way to help you without knowing more details about the file format. Will each title have 3 lines of data? After the title will always have a blank line (in the last title has 2)? Columns will always be separated by 2 spaces?
– Jéf Bueno
You’re right. Each title will have 3 rows of data, it will always have a blank row and the columns are separated by 2 spaces. Always following this pattern.
– ITALO ARAUJO
I will correct the posting. Thank you for the comment!
– ITALO ARAUJO