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).
You can use `String.StartsWith()` to detect "FieldName". Then `String.Split()` with a parameter of null to split by whitespace. This will get you your fieldname and length strings.