Note: This is documentation for version 5.4 of Source. For a different version of Source, select the relevant space by using the Spaces menu in the toolbar above
Commandline Post Processor
Plugin was written by bri26b (Unlicensed) from CSIRO to help him process results from the commandline.
General Info
License | As-is, use at your own risk |
Type | free |
Current version | 1.0 |
Plugin Description
Used on the command line to post process results:
private static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-AU"); if (args.Count() == 3) { string mappingFile = args[0]; string resultsFile = args[1]; string outputFile = args[2]; //Create mapping var mapping = new Dictionary<string, string>(); string[] mappingLines = File.ReadAllLines(mappingFile); foreach (var line in mappingLines) { var trimLine = line.Trim(); if (!String.IsNullOrEmpty(trimLine)) { string[] keyValue = trimLine.Split(new[] {','}); mapping[keyValue[0]]= keyValue[1]; } } //Read Riversystem.commandline results file string[] results = File.ReadAllLines(resultsFile); int numDataLines = results.Count() - 1; //Use first line to identify relevant columns string[] columnNames = results[0].Split(new[] {','}); var columnName2Idx = new Dictionary<string, int>(); for (int i = 0; i < columnNames.Count(); i++) { if (mapping.ContainsKey(columnNames[i])) columnName2Idx[columnNames[i]]= i; } //Build up the list ... done this way to only traverse the results once var outList = new SortedDictionary<int, string>(); for (int i = 1; i < results.Count(); i++) { string[] splittedresults = results[i].Split(new[] {','}); int j = 0; DateTime dt = Convert.ToDateTime(splittedresults[0]); foreach (var kvp in mapping) { string result = kvp.Value + " " + dt.ToString("dd/MM/yyyy 12:mm:ss") + " " + splittedresults[columnName2Idx[kvp.Key]]; int idx = numDataLines*j + i - 1; outList[idx] = result; j++; } } using (var outfile = new StreamWriter(outputFile)) for (int i = 0; i < outList.Count; i++) outfile.WriteLine(outList[i]); } }
Source Code
Source code available in http://hg.ewater.com.au/sourceplugin.commandlinepostprocessor
Â