public static TsvDataSheet Download(AbsoluteUri location) { if (null == location) { throw new ArgumentNullException("location"); } TsvDataSheet tsv = null; var request = WebRequest.Create((Uri)location); using (var response = request.GetResponse()) { using (var stream = response.GetResponseStream()) { if (null != stream) { using (var reader = new StreamReader(stream)) { #if NET20 var file = new FileInfo(StringExtensionMethods.FormatWith("{0}.tsv", AlphaDecimal.Random())); FileInfoExtensionMethods.Create(file, reader.ReadToEnd()); #else var file = new FileInfo("{0}.tsv".FormatWith(AlphaDecimal.Random())); file.Create(reader.ReadToEnd()); #endif tsv = new TsvDataSheet(file); } } } } return tsv; }
private static void Process(TsvDataSheet sheet) { Console.WriteLine(Resources.TsvFileInfo, sheet.Info.FullName); var count = 0; foreach (var entry in sheet) { if (0 == count) { var columns = new StringBuilder(); foreach (var key in entry.Keys) { var format = 0 == columns.Length ? "Columns: " : "{0} ".FormatWith(Environment.NewLine); columns.Append(format + key); } Console.WriteLine(columns); } count++; } Console.WriteLine(Resources.TsvEntryCount, count); }
public void op_IEnumerable_GetEnumerator() { using (var file = new TempFile()) { file.Info.AppendLine("name"); file.Info.AppendLine("Example"); IEnumerable enumerable = new TsvDataSheet(file.Info); foreach (var entry in enumerable.Cast<KeyStringDictionary>()) { Assert.Equal("Example", entry["name"]); } } }
public void usage(TsvDataSheet tsv) { Assert.Equal("A1", tsv.First()["A"]); Assert.Equal("B2", tsv.Last()["B"]); }
public void usage_whenMultipleParameters(TsvDataSheet one, TsvDataSheet two) { Assert.Equal("one", one.First()["COLUMN"]); Assert.Equal("two", two.First()["COLUMN"]); }
public void usage(TsvDataSheet sheet) { Assert.Equal("A1", sheet.First()["A"]); Assert.Equal("B2", sheet.Last()["B"]); }