I want to know if it is possible to read with text file faster and smarter.
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 the "part" using the "part"? I do not want to iterate over each line.
Would it be possible for LINQ start with ID:1; and ended with ENDCARD: :?
The reason for this is that I want to create an object for each "part" ...
I had something like this:
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) { }
source share