本文整理匯總了C#中System.Data.DataTable.FromCSV方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.FromCSV方法的具體用法?C# DataTable.FromCSV怎麽用?C# DataTable.FromCSV使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Data.DataTable
的用法示例。
在下文中一共展示了DataTable.FromCSV方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FromCSVTest
public void FromCSVTest()
{
DataTable data = new DataTable();
string filename = string.Empty; // TODO: Initialize to an appropriate value
data.FromCSV( @"D:\DK_information\output.csv","");
data.ToCSV(@"D:\DK_information\output2.csv");
}
示例2: Initialize
/// <summary>
/// Initializes all models
/// </summary>
public void Initialize()
{
LogThis("Initializing");
LogThis("Reading catchments");
LoadCatchments();
LogThis(AllCatchments.Values.Count + " catchments read");
LoadCoastalZone();
LoadLakes(); //This should be made dependent on the actual submodels
StateVariables = new DataTable();
if (InitialConditionsfile != null) //Work from previous simulation
{
LogThis("Reading initial conditions from previous simulation. FileName: " + InitialConditionsfile.FileName);
StateVariables.FromCSV(InitialConditionsfile.FileName, InitialConditionsfile.ColumnNames.First());
LogThis("Have read " + StateVariables.Rows.Count);
//Removing rows that are not within the requested time period
for (int i = StateVariables.Rows.Count - 1; i >= 0; i--)
{
DateTime time = (DateTime) StateVariables.Rows[i]["Time"];
if (time < Start || time > End)
StateVariables.Rows.RemoveAt(i);
}
for (int i = 0; i < StateVariables.Columns.Count; i++)
LogThis(StateVariables.Columns[i].ColumnName);
//Read in catchment values
CurrentTime = Start;
foreach (var c in AllCatchments.Values)
{
var catchm = StateVariables.Rows.Find(new object[] { c.ID, StateVariables.Rows[0][1] });
if (catchm == null)
LogThis("Could not find inital conditions for cathment with ID = " + c.ID);
else
{
var precipvalues = new List<double>();
c.Temperature = new TimeStampSeries();
c.Leaching = new TimeStampSeries();
var m11values = new List<double>();
while (CurrentTime <= End)
{
var CurrentState = StateVariables.Rows.Find(new object[] { c.ID, CurrentTime });
if (!CurrentState.IsNull("Precipitation"))
precipvalues.Add((double)CurrentState["Precipitation"]);
if (!CurrentState.IsNull("Air Temperature"))
c.Temperature.Items.Add(new TimeStampValue(CurrentTime, (double)CurrentState["Air Temperature"]));
if (!CurrentState.IsNull("M11Flow"))
m11values.Add((double)CurrentState["M11Flow"] / (DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400.0));
if (!CurrentState.IsNull("Leaching"))
c.Leaching.Items.Add(new TimeStampValue(CurrentTime, (double)CurrentState["Leaching"] / (DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400.0)));
CurrentTime = CurrentTime.AddMonths(1);
}
if (m11values.Count > 0)
{
c.M11Flow = new ZoomTimeSeries();
c.M11Flow.GetTs(TimeStepUnit.Month).AddRange(Start, m11values);
}
if (precipvalues.Count > 0)
{
c.Precipitation = new ZoomTimeSeries() { Accumulate = true };
c.Precipitation.GetTs(TimeStepUnit.Month).AddRange(Start, precipvalues);
}
CurrentTime = Start;
}
}
CurrentTime = Start;
}
else
{
StateVariables.Columns.Add("ID", typeof(int));
StateVariables.Columns.Add("Time", typeof(DateTime));
StateVariables.Columns.Add("ObservedFlow", typeof(double));
StateVariables.Columns.Add("ObservedNitrate", typeof(double));
StateVariables.Columns.Add("M11Flow", typeof(double));
StateVariables.Columns.Add("NetM11Flow", typeof(double));
StateVariables.Columns.Add("Precipitation", typeof(double));
StateVariables.Columns.Add("Air Temperature", typeof(double));
StateVariables.Columns.Add("DownStreamOutput", typeof(double));
StateVariables.Columns.Add("Leaching", typeof(double));
StateVariables.PrimaryKey = new DataColumn[] { StateVariables.Columns[0], StateVariables.Columns[1] };
}
if (Stations!=null && StationData!=null)
LoadStationData(Stations, StationData.FileName, Start, End);
foreach (var c in AllCatchments.Values)
{
c.SourceModels = SourceModels;
c.InternalReduction = InternalReductionModels;
//.........這裏部分代碼省略.........
示例3: ToExcelTemplateTest
public void ToExcelTemplateTest()
{
DataTable data = new DataTable();
data.FromCSV(@"D:\DK_information\output_temp2.csv","");
string TemplateFilename = @"D:\DK_information\Output\DetailedStationOutputTemplate.xls";
Extensions.ToExcelTemplate(data, TemplateFilename, @"D:\DK_information\Output");
}
示例4: ToCSVTest
public void ToCSVTest()
{
DataTable data = new DataTable();
data.FromCSV(@"D:\DK_information\output_temp2.csv","");
int ID15 = 82101044;
Extensions.ToCSV(data, ID15, @"D:\DK_information\ts.csv");
}
示例5: ExtractTimeSeriesTest
public void ExtractTimeSeriesTest()
{
DataTable data = new DataTable();
data.FromCSV(@"D:\DK_information\output_temp2.csv", "");
string parametername = "Groundwater";
var actual = Extensions.ExtractTimeSeries(data, parametername);
}
示例6: ToCSVTest1
public void ToCSVTest1()
{
DataTable data = new DataTable();
data.FromCSV(@"D:\DK_information\output_temp2.csv", "");
string parametername = "Groundwater";
string filename = @"D:\DK_information\groundwater.csv";
Extensions.ToCSV(data, parametername, filename);
}