Additional Templates

General Templates

Compare a field as a number
Find values that contain non-numeric characters
Find values that appear only once


General Templates

Compare a field as a number
This template compares the first field against a whole number, and gets all lines where that field is less than the number. To compare against numbers with a decimal point, simplay replace ToInt with ToFloat.
var query = (
  from line in inputFile
  where line[0].ToInt() < 100
  select line
);
Find values that contain non-numeric characters
This template finds all lines that contain any non-numeric characters in the first field. It uses a regular expression to list characters that are allowed, and then find any value that contains a character that is not in that list. If you are dealing with other types of numbers, such as decimal, negative or currency, then you can add some extra characters to the list. (ex. @"[^0-9.+\-$]")
var query = (
  from line in inputFile
  where line[0].Like(@"[^0-9]")
  select line
);
Find values that appear only once
This template finds all values that appear only once in the field. Notice the way that it uses the results of the Freq() function. It is actually an object that has three parameters: Text, Count and Percent. These can then be accessed in subsequent functions as show. Here we take only items that have a count of one, and since we don't need to see the counts and percentages any more (we know there is only one) we use the Select() function to display only the actual text of the value.
var query = (
  from line in inputFile
  where line[0].Like(@"[^0-9]")
  select line[0]
).Freq().Where(f => f.Count == 1).Select(f => f.Text);