I want to know if it is possible to read from a text file in a faster and smarter way.
This is a typical format of my data in a text file:
Call this "part":
ID:1; FIELD1 :someText; FIELD2 :someText; FIELD3 :someText; FIELD4 :someText; FIELD5 :someText; FIELD6 :someText; FIELD7 :someText; FIELD8 :someText; END_ID : 01: someData; 02: someData; ... ... 48: someData; ENDCARD: I have thousands of them in a text file.
Is it possible to use LINQ to read it "part" by "part"? I don't want to loop through every single line.
Will it be possible for LINQ to start at ID:1; and end at ENDCARD:?
The reason for this is that i want to create a object for every "part"...
I had something like this in mind:
string[] lines = System.IO.File.ReadAllLines(SomeFilePath); //Cleaning up the text file of unwanted text var cleanedUpLines = from line in lines where !line.StartsWith("FIELD1") && !line.StartsWith("FIELD5") && !line.StartsWith("FIELD8") select line.Split(':'); //Here i want to LINQtoText "part" by "part" //This i do not want to do!!! foreach (string[] line in cleanedUpLines) { }