Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your best bet is probably to define a data structure for the data and read the entire file (or at least the parts you want) into that structure. Then you can interact with that structure in memory and manipulate it however you need.</p> <p>For example, you might define define a class such as:</p> <pre><code>public class SomeObject // give it a more meaningful name, of course { public DateTime Start { get; set; } public DateTime Stop { get; set; } } </code></pre> <p>Then you'd perhaps add a static factory to that class which de-serializes from a given string (which the application obtains from the file, since the class itself shouldn't have knowledge of the file but just the data within). It could be something as simple as <a href="http://msdn.microsoft.com/en-us/library/dd383503.aspx" rel="nofollow">reading all the lines from the file</a> and passing the enumeration of lines to that factory method. Then that factory method would <a href="http://msdn.microsoft.com/en-us/library/tabh47cf.aspx" rel="nofollow">parse each line</a> for the data.</p> <p>It looks like the data is pipe-delimeted, so something like this might be a good start:</p> <pre><code>public static SomeObject Deserialize(IEnumerable&lt;string&gt; input) { var result = new SomeObject(); foreach (var dataLine in input.Skip(1)) { var dataElements = dataLine.Split('|'); result.Start = DateTime.Parse(dataElements.Skip(6).First()); result.Stop = DateTime.Parse(dataElements.Skip(7).First()); } return result; } </code></pre> <p>You'll probably also want to add in some error checking on the input, using <code>TryParse</code> on the data if it's not always directly parseable, a little defensive programming here or there. But you get the idea.</p> <p>Then manipulating the data in memory becomes trivial. You can get your <code>Start</code> column, for example, from a list of these objects:</p> <pre><code>var startTimes = listOfObjects.Select(o =&gt; o.Start); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload