139 142 :No. nodes, No. modes:
part
new modal =
refmod
mass = 2.000D+03
nelastq = 142
ielastq ( 1) = Eigen Mode 7 : 3.895 Hz
ielastq ( 2) = Eigen Mode 8 : 8.914 Hz
ielastq ( 3) = Eigen Mode 9 : 10.455 Hz
ielastq ( 4) = Eigen Mode 10 : 10.633 Hz
ielastq ( 5) = Eigen Mode 11 : 14.134 Hz
ielastq ( 6) = Eigen Mode 12 : 14.230 Hz
ielastq ( 7) = Eigen Mode 13 : 14.839 Hz
ielastq ( 8) = Eigen Mode 14 : 15.543 Hz
ielastq ( 9) = Eigen Mode 15 : 16.810 Hz
ielastq ( 10) = Eigen Mode 16 : 16.921 Hz
ielastq ( 11) = Eigen Mode 17 : 17.858 Hz
ielastq ( 12) = Eigen Mode 18 : 18.822 Hz
ielastq ( 13) = Eigen Mode 19 : 19.006 Hz
ielastq ( 14) = Eigen Mode 20 : 19.335 Hz
ielastq ( 15) = Eigen Mode 21 : 19.430 Hz
ielastq ( 16) = IRM 1 : 59.876 Hz
ielastq ( 17) = IRM 2 : 60.495 Hz
ielastq ( 18) = IRM 3 : 61.735 Hz
ielastq ( 19) = IRM 4 : 64.041 Hz
ielastq ( 20) = IRM 5 : 67.065 Hz
ielastq ( 21) = IRM 6 : 67.663 Hz
ielastq ( 22) = IRM 7 : 69.528 Hz
end refmod
Some Text Data
.
.
.
public static string[] GetIElastiq(int id)
{
// some code here
}
ielastq ( 10) = Eigen Mode 16 : 16.921 Hz
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace EE_Q29167461
{
class Program
{
static void Main(string[] args)
{
var contents = System.IO.File.ReadAllLines($"{typeof(Program).Namespace}.txt").Where(x => x.IndexOf("ielastq", StringComparison.OrdinalIgnoreCase) > -1);
var matches = contents.GetIElastiqById(10);
foreach (var match in matches)
{
Console.WriteLine(match);
}
Console.ReadLine();
}
}
static class Extensions
{
public static IEnumerable<string> GetIElastiqById(this IEnumerable<string> data, int id)
{
var parameter = default(int);
return data.Where(x =>
Regex.Match(x, @"\(([^)]+)\)").Groups.Count > 1 &&
int.TryParse(Regex.Match(x, @"\(([^)]+)\)").Groups[1].Value.Trim(), out parameter) &&
parameter == id
);
}
}
}
Produces the following output -namespace ConsoleCS
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
public class Program
{
public static void Main(string[] args)
{
IElastq ielastq = new IElastq(@"c:\temp\data.txt");
var dataPoint = ielastq[10];
Console.WriteLine(dataPoint);
Console.WriteLine("\nDone.");
Console.ReadLine();
}
}
public class IElastq
{
private Dictionary<int, Tuple<string, string, double>> iElastq = new Dictionary<int, Tuple<string, string, double>>();
public Tuple<string, string, double> this[int i]
{
get
{
return this.iElastq[i];
}
}
public IElastq(string filename)
{
using (StreamReader file = new StreamReader(filename))
{
string line;
bool inRefMod = false;
while ((line = file.ReadLine()) != null)
{
line = line.Trim();
if (inRefMod)
{
if (line.StartsWith("ielastq"))
{
int number = int.Parse(line.Substring(9, 4));
string description = line.Substring(33, 17).Trim();
double frequency = double.Parse(line.Substring(51, 14), new CultureInfo("en-US"));
string unit = line.Substring(65, line.Length - 65);
this.iElastq.Add(number, new Tuple<string, string, double>(description, unit, frequency));
}
if (line.Equals("end refmod"))
{
break;
}
}
if (line.Equals("refmod"))
{
inRefMod = true;
}
}
}
}
}
}
ielastq ( 10) = Eigen Mode 16 : 16.921 Hz
Like below; Eigen Mode
16
16.921
Just "loop" over the input file / stream by reading line for line. Seems like it is sufficient to look for lines with "ielastq". Parsing can be done here by splitting the line using fixed positions with SubString.