segunda-feira, 7 de maio de 2012

FxGqlC: Define the columns of an input text file using a regular expression


An input text file can be parsed into columns using a regular expression, using the new FROM-clause option " -Columns='<regular expression>' ".  The input line is matched against the regular expression.  If there is no match, the line is ignored. If the line matches, the first match is used, and the columns are filled with the named "capture groups" of the regulare expression.  The syntax to define a capture group in .net regular expressions is: "(?<MyColumnName>MyFilter)".  For example: "(?<Count>\d+)". The column name can then be used in any expression like the WHERE-clause.  This feature is added in version 2.1.

Example:
select distinct [Tournament] from ['Tennis-ATP-2011.csv' -columns='^(?<ATP>.*?)\t(?<Location>.*?)\t(?<Tournament>.*?)\t.*?$']

More information on using regular expressions, can be found on this site: http://www.regular-expressions.info/ .
For the usage of "Capture Groups", see the section "Named Capture with .NET’s System.Text.RegularExpressions" on this link: http://www.regular-expressions.info/named.html

More information on: https://sites.google.com/site/fxgqlc

Nenhum comentário:

Postar um comentário