Question: I've to calculate the différence between two Dates : TODAY() and DATE\_DEB\_VAC.
With Oracle, it's kinda easy : `TODAY()-DATE_DEB_VAC` -> give the number of day between those 2 date.

But I've to do it with in an ETL (GENIO). I've a column to stock it like that :
`NUMBER_DAY_DIFF (NUMBER 10) = TODAY()-DATE_DEB_VAC`. But it's impossible to stock it cause it's 2 date.

How can i do this ? :(

Answer: 
You can use `SkipWhile(l => !l.TrimStart().StartsWith("Field Name")).Skip(1)`:

```
Dictionary<string, string> allFieldLengths = File.ReadLines("path")
    .SkipWhile(l => !l.TrimStart().StartsWith("Field Name")) // skips lines that don't start with "Field Name"
    .Skip(1)                                       // go to next line
    .SkipWhile(l => string.IsNullOrWhiteSpace(l))  // skip following empty line(s)
    .Select(l =>                                   
    {                                              // anonymous method to use "real code"
        var line = l.Trim();                       // remove spaces or tabs from start and end of line
        string[] token = line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        return new { line, token };                // return anonymous type from 
    })
    .Where(x => x.token.Length == 2)               // ignore all lines with more than two fields (invalid data)
    .Select(x => new { FieldName = x.token[0], Length = x.token[1] })
    .GroupBy(x => x.FieldName)                     // groups lines by FieldName, every group contains it's Key + all anonymous types which belong to this group
    .ToDictionary(xg => xg.Key, xg => string.Join(",", xg.Select(x => x.Length)));

```

`line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)` will split by space and tabs and ignores all empty spaces. Use `GroupBy` to ensure that all keys are unique in the dictionary. In the case of duplicate field-names the `Length` will be joined with comma.

---

**Edit**: since you have requested a non-LINQ version, here is it:

```
Dictionary<string, string> allFieldLengths = new Dictionary<string, string>();
bool headerFound = false;
bool dataFound = false;
foreach (string l in File.ReadLines("path"))
{
    string line = l.Trim();
    if (!headerFound && line.StartsWith("Field Name"))
    {
        headerFound = true;
        // skip this line:
        continue;
    }
    if (!headerFound)
        continue;
    if (!dataFound && line.Length > 0)
        dataFound = true;
    if (!dataFound)
        continue;
    string[] token = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    if (token.Length != 2)
        continue;
    string fieldName = token[0];
    string length = token[1];
    string lengthInDict;
    if (allFieldLengths.TryGetValue(fieldName, out lengthInDict))
        // append this length
        allFieldLengths[fieldName] = lengthInDict + "," + length;
    else
        allFieldLengths.Add(fieldName, length);
}

```

I like the LINQ version more because it's much more readable and maintainable (imo).
Based on the assumption that the position of the header line is fixed, we may consider actual key-value pairs to start from the 9th line. Then, using the `ReadAllLines` method to return a `String` array from the file, we just start processing from index 8 onwards:

```
  string[] lines = File.ReadAllLines(filepath);
  Dictionary<string,int> pairs = new Dictionary<string,int>();

    for(int i=8;i<lines.Length;i++)
    {
        string[] pair = Regex.Replace(lines[i],"(\\s)+",";").Split(';');
        pairs.Add(pair[0],int.Parse(pair[1]));
    }

```

This is a skeleton, not accounting for exception handling, but I guess it should get you started.