コード例 #1
0
        public void RoundtripTable()
        {
            // Test that if we download and then reupload, it's ok.
            var account = GetStorage();

            var       source   = from x in Enumerable.Range(1, 200) select new { N = x, N2 = x * x };
            DataTable dtSource = DataTable.New.FromEnumerable(source);

            string tableName = "csvtesttable";

            dtSource.SaveToAzureTable(account, tableName); // original upload

            DataTable        dtDownload1 = DataTable.New.ReadAzureTableLazy(account, tableName);
            MutableDataTable dtA         = DataTable.New.GetMutableCopy(dtDownload1);

            // this writes back to the source that dtDownload1 was streaming from.
            // But we already copied to dtA, so safe to overwrite.
            dtA.SaveToAzureTable(account, tableName); // 2nd upload

            DataTable        dtDownload2 = DataTable.New.ReadAzureTableLazy(account, tableName);
            MutableDataTable dtB         = DataTable.New.GetMutableCopy(dtDownload2);

            // Everything except timestamps should match.
            dtA.DeleteColumns("TimeStamp");
            dtB.DeleteColumns("TimeStamp");
            Utility.AssertEquals(dtA, dtB);
        }
コード例 #2
0
        public void DeleteColumns()
        {
            MutableDataTable dt = GetTable();

            dt.DeleteColumns("first");

            AnalyzeTests.AssertEquals(
                @"last
Smith
Jones
", dt);
        }
コード例 #3
0
        // removes columns with empty data
        public static string CleanByColumns(string filename, params string[] ignoreproperties)
        {
            MutableDataTable dt = DataAccess.DataTable.New.ReadCsv(filename);

            var colsdlt = dt.Columns.Select(col =>
            {
                var v = col.Values.Any(_ => _ == "");
                return(v ? col.Name : null);
            })
                          .Where(_ => _ != null)
                          .ToArray();


            var a = colsdlt.Except(ignoreproperties);

            dt.DeleteColumns(a.ToArray());

            return(dt.SaveToString());
        }
コード例 #4
0
        public void DeleteColumnsEmptyArray()
        {
            MutableDataTable dt = GetTable();

            dt.DeleteColumns();
        }