本文整理汇总了C#中CsvRow类的典型用法代码示例。如果您正苦于以下问题:C# CsvRow类的具体用法?C# CsvRow怎么用?C# CsvRow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CsvRow类属于命名空间,在下文中一共展示了CsvRow类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Generate
public void Generate()
{
foreach (IAdj adj in _adjs)
{
SortedList<DateTime, AdjRateDatum> adjRateData = CreateAdjRateData(adj);
//String dir = Directory.GetCurrentDirectory();
//String path = dir + "\\" + _excelAdjResultFileName;
CsvFileWriter writer = new CsvFileWriter(String.Format("{0}_result.csv", adj.ToString()));
WriteHeader(writer);
foreach (KeyValuePair<DateTime, AdjRateDatum> datum in adjRateData)
{
CsvRow row = new CsvRow();
row.Add(datum.Key.ToString("yyyy-MM-dd"));
row.Add(datum.Value.KospiRate.ToString("n5"));
row.Add(datum.Value.KtbRate.ToString("n5"));
row.Add(datum.Value.DollarRate.ToString("n5"));
writer.WriteRow(row);
}
writer.Close();
}
}
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:26,代码来源:AdjExcelAdjResultConverter.cs
示例2: CsvLoadTripRoutes
public static void CsvLoadTripRoutes(string filename, bool lngFirst)
{
// load trip routes
Dictionary<string, LinkedList<Waypoint>> routes = new Dictionary<string, LinkedList<Waypoint>>();
using (CsvFileReader reader = new CsvFileReader(filename))
{
CsvRow row = new CsvRow();
while (reader.ReadRow(row, ','))
{
string routeID = row[0];
double distance = 0;
double lat = Convert.ToDouble(lngFirst ? row[2] : row[1]);
double lng = Convert.ToDouble(lngFirst ? row[1] : row[2]);
if (routes.ContainsKey(routeID))
distance = routes[routeID].First.Value.GetDistance(new Location(lat, lng, "null"));
Waypoint waypoint = new Waypoint(lat, lng, TimeSpan.Parse(row[3]), distance, row[4].Replace("\"", ""));
// Scenario #1
if (!routes.ContainsKey(routeID))
routes[routeID] = new LinkedList<Waypoint>();
routes[routeID].AddLast(waypoint);
}
}
foreach (LinkedList<Waypoint> w in routes.Values)
{
Route r = new Route(w.ToArray());
string key = Route.GetKey(r.start, r.end);
MapTools.routes.Add(key, r);
}
}
开发者ID:TripThru,项目名称:Gateway,代码行数:31,代码来源:1397817436$MapTools.cs
示例3: kToSqlCreateTable
public static string kToSqlCreateTable(string tblFileName, string csvFilePath)
{
string cmdText = string.Empty;
using (CsvFileReader reader = new CsvFileReader(csvFilePath))
{
CsvRow row = new CsvRow();
bool isHeader = true;
string tTblFile = tblFileName.Substring(0, tblFileName.IndexOf("_"));
Console.WriteLine("c o d i n g . . . t r a n s c o d i n g . . . t r a n s . . . . . ");
cmdText += string.Format("DROP TABLE IF EXISTS `{0}`;", tTblFile) + Environment.NewLine;
cmdText += string.Format("CREATE TABLE IF NOT EXISTS `{0}` (", tTblFile) + Environment.NewLine;
while (reader.ReadRow(row))
{
if (isHeader)
{
isHeader = false;
continue;
}
string tRowType = kToMySQLTypeStatement(row);
cmdText += "\t" + (tRowType.Equals(",") ? "" : tRowType) + Environment.NewLine;
}
cmdText = cmdText.Remove(cmdText.LastIndexOf(","), 1);
cmdText += ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" + Environment.NewLine;
Console.WriteLine(cmdText);
Console.WriteLine("DONE !!!");
reader.Close();
}
return cmdText;
}
开发者ID:cgabilla,项目名称:cKarp,代码行数:34,代码来源:SqlScriptTrans.cs
示例4: Main
//static void Main(string[] args)
//{
// CsvRow row = new CsvRow();
// CsvFileReader reader = new CsvFileReader("C:\\temp\\XICData.csv");
// while (reader.ReadRow(row))
// {
// Console.Out.WriteLine(row[0] + " -> " + row[1]);
// }
// Console.Read();
//}
static void Main(string[] args)
{
List<XICDataPoint> xicData = new List<XICDataPoint>();
CsvRow row = new CsvRow();
CsvFileReader reader = new CsvFileReader("C:\\temp\\XICData.csv");
while (reader.ReadRow(row))
{
Console.Out.WriteLine(row[0] + " -> " + row[1]);
int scanNumber;
double intensity;
if (int.TryParse(row[0], out scanNumber) && double.TryParse(row[1], out intensity))
xicData.Add(new XICDataPoint { scanNumber = scanNumber, intensity = intensity });
}
PeakFinder finder = new PeakFinder();
foreach (var peakData in finder.GetPeaks(xicData))
{
Console.Out.WriteLine(peakData.startScan + " -> " , peakData.endScan);
foreach (var intensity in peakData.intensityValues)
{
Console.Out.WriteLine("Intensity = " + intensity);
}
}
Console.Read();
}
开发者ID:sachindeshpande,项目名称:Projects,代码行数:38,代码来源:Program.cs
示例5: RunCommand
public void RunCommand(string cmd)
{
CsvRow row = new CsvRow();
row.Add(DateTime.Now.format("dd-MM-yyyy HH:mm:ss"));
row.Add(this.Com);
row.Add(this.Name);
try
{
string msg = string.Format(cmd, this.board, this.pos);
row.Add(msg);
if (App.listSerialPort != null)
{
for (int i = 0; i < App.listSerialPort.Count; i++)
{
if (this.Com.ToLower() == App.listSerialPort[i].PortName.ToLower())
{
App.listSerialPort[i].sendCommand(msg);
break;
}
}
}
}
catch (Exception)
{
}
App.RowsSend.Add(row);
}
开发者ID:iceriver102,项目名称:alta-mtc-version-2,代码行数:29,代码来源:Alarm.cs
示例6: WriteRow
public void WriteRow(CsvRow row)
{
StringBuilder stringBuilder = new StringBuilder();
bool flag = true;
foreach (string current in row)
{
if (!flag)
{
stringBuilder.Append(',');
}
if (current.IndexOfAny(new char[]
{
'"',
','
}) != -1)
{
stringBuilder.AppendFormat("\"{0}\"", current.Replace("\"", "\"\""));
}
else
{
stringBuilder.Append(current);
}
flag = false;
}
row.LineText = stringBuilder.ToString();
this.WriteLine(row.LineText);
}
开发者ID:Padungsak,项目名称:efinTradePlus,代码行数:27,代码来源:CsvFileWriter.cs
示例7: readPlayers
public Dictionary<string, Player> readPlayers()
{
Dictionary<string, Player> listPlayers = new Dictionary<string, Player>();
using (CsvFileReader reader = new CsvFileReader(file))
{
CsvRow row = new CsvRow();
while (reader.ReadRow(row))
{
listPlayers.Add(row[Constants.FName], new Player(row[Constants.FName], boolFromString(row[Constants.FBoolTerran]),
boolFromString(row[Constants.FBoolZerg]), boolFromString(row[Constants.FBoolProtoss]), boolFromString(row[Constants.FBoolRandom])));
Player temp = listPlayers[row[Constants.FName]];
int.TryParse(row[Constants.FVictoryTerran], out temp.Victory[Constants.Terran]);
int.TryParse(row[Constants.FVictoryZerg], out temp.Victory[Constants.Zerg]);
int.TryParse(row[Constants.FVictoryProtoss], out temp.Victory[Constants.Protoss]);
int.TryParse(row[Constants.FVictoryRandom], out temp.Victory[Constants.Random]);
int.TryParse(row[Constants.FDefeatTerran], out temp.Defeat[Constants.Terran]);
int.TryParse(row[Constants.FDefeatZerg], out temp.Defeat[Constants.Zerg]);
int.TryParse(row[Constants.FDefeatProtoss], out temp.Defeat[Constants.Protoss]);
int.TryParse(row[Constants.FDefeatRandom], out temp.Defeat[Constants.Random]);
int.TryParse(row[Constants.FEloTerran], out temp.Elo[Constants.Terran]);
int.TryParse(row[Constants.FEloZerg], out temp.Elo[Constants.Zerg]);
int.TryParse(row[Constants.FEloProtoss], out temp.Elo[Constants.Protoss]);
int.TryParse(row[Constants.FEloRandom], out temp.Elo[Constants.Random]);
}
}
return listPlayers;
}
开发者ID:dosimont,项目名称:sc2_matchmaker,代码行数:27,代码来源:PlayerReader.cs
示例8: EventPointsReader
public EventPointsReader(String filePath, Boolean skipHeader)
{
this.EventPoints = new List<EventPoint>();
CsvFileReader reader = new CsvFileReader(filePath);
Boolean headerSkipped = false;
while (true)
{
CsvRow row = new CsvRow();
if (reader.ReadRow(row))
{
if ((skipHeader && headerSkipped) ||
!skipHeader)
{
EventPoint ep = new EventPoint();
ep.LongCode = row[0];
ep.ShortCode = row[1];
ep.DateTimeFrom = DateTime.ParseExact(row[2], "yyyy-MM-dd HH:mm:ss.fff", null);
ep.DateTimeTo = DateTime.ParseExact(row[3], "yyyy-MM-dd HH:mm:ss.fff", null);
ep.RangeMax = Convert.ToDouble(row[4]);
ep.RangeMin = Convert.ToDouble(row[5]);
this.EventPoints.Add(ep);
}
headerSkipped = true;
}
else
{
break;
}
}
}
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:34,代码来源:EventPointsReader.cs
示例9: WriteToCsvFile
public static void WriteToCsvFile(this DataTable dataTable, string filePath)
{
CsvFileWriter writer = new CsvFileWriter(filePath);
StringBuilder fileContent = new StringBuilder();
CsvRow row = new CsvRow();
foreach (var col in dataTable.Columns)
row.Add(col.ToString());
writer.WriteRow(row);
foreach (DataRow dr in dataTable.Rows)
{
row = new CsvRow();
foreach (var column in dr.ItemArray)
{
row.Add(column.ToString());
}
writer.WriteRow(row);
}
writer.Close();
dataTable = null;
System.Console.WriteLine(string.Format("Done writing to {0}.", filePath));
}
开发者ID:cgabilla,项目名称:cKarp,代码行数:25,代码来源:DataTableExtensions.cs
示例10: loadSNPSPToolStripMenuItem_Click
private void loadSNPSPToolStripMenuItem_Click(object sender, EventArgs e)
{
_openFileDialog.FileName = "SNPCC.csv";
_openFileDialog.Filter = "csv files (*.csv)|*.csv";
_openFileDialog.DefaultExt = "txt";
_openFileDialog.FilterIndex = 2;
_openFileDialog.AddExtension = true;
if (_openFileDialog.ShowDialog() == DialogResult.OK)
{
string fileName = _openFileDialog.FileName;
CsvFileReader csv = new CsvFileReader(fileName);
char[] _separators = new char[] { '\n', '"', ',' };
CsvRow row = new CsvRow();
bool entering = true;
while (entering == true)
{
entering = csv.ReadRow(row);
staters.Add(new Stater(row[1], row[0]));
char[] bar = row[2].ToCharArray();
string bs = Convert.ToString(bar[0]) + Convert.ToString(bar[1]) + Convert.ToString(bar[2]) + Convert.ToString(bar[3]);
staters[staters.Count - 1].Barcode = Convert.ToInt32(bs);
staters[staters.Count - 1].City = row[3];
staters[staters.Count - 1].County = row[4];
}
csv.Close();
staters.RemoveAt(staters.Count - 1);
List<Stater> testing = staters;
}
}
开发者ID:ThaddeusT,项目名称:StaterPhotoSuite,代码行数:30,代码来源:Form1.cs
示例11: citTotalLoadsFload
public citTotalLoadsFload(CsvRow row)
{
this.KycrspFundno = Convert.ToInt32(row[0]);
this.FrontLoad = Convert.ToDouble(row[1]);
this.FrontGroupNo = row[2];
this.Fflbegdt = FuncoesAux.StringToDateTime(row[3]);
this.Fflenddt = FuncoesAux.StringToDateTime(row[4]);
}
开发者ID:MiguelCosta,项目名称:Financas,代码行数:8,代码来源:citTotalLoadsFload.cs
示例12: import
public void import(string fileName, int headerRow)
{
List<string> columns = new List<string>();
List<Dictionary<string, string>> rows = new List<Dictionary<string,string>>();
// Read sample data from CSV file
using (CsvFileReader reader = new CsvFileReader(fileName))
{
int lineNumber = 0;
CsvRow row = new CsvRow();
while (reader.ReadRow(row))
{
if (lineNumber == headerRow)
{
// Read Header Values
foreach (string s in row)
{
columns.Add(s.Replace(" ", ""));
}
}
else if (lineNumber > headerRow)
{
int columnIndex = 0;
Dictionary<string, string> dataRow = new Dictionary<string,string>();
foreach (string s in row)
{
dataRow.Add(columns[columnIndex], s);
++columnIndex;
}
rows.Add(dataRow);
}
++lineNumber;
}
}
// Output using code generator
// IList<BusinessRule> rules = new List<BusinessRule>();
// rules.Add(new BusinessRule
// {
// ErrorCode = "AIRBR1001",
// RuleNumber = "1095C-006",
// Description = "Form 1095C 'TINRequestTypeCd' in 'EmployeeInfoGrp' must have a value equal to 'INDIVIDUAL_TIN'.",
// ErrorCategory = "Incorrect Data",
// Severity = "Report Error",
// Status = "Active"
// });
CodeCompileUnit code = new CodeCompileUnit();
CodeNamespace namespaces = new CodeNamespace();
namespaces.Imports.Add(new CodeNamespaceImport("System"));
}
开发者ID:xpk-rodaire,项目名称:GitHubVS2013,代码行数:57,代码来源:BizRulesImporter.cs
示例13: WriteHeader
void WriteHeader(CsvFileWriter writer)
{
CsvRow row = new CsvRow();
row.Add("Date");
row.Add("KospiRate");
row.Add("KtbRate");
row.Add("DollarRate");
writer.WriteRow(row);
}
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:10,代码来源:AdjExcelAdjResultConverter.cs
示例14: WriteHeader
void WriteHeader(CsvFileWriter writer)
{
CsvRow row = new CsvRow();
row.Add("DateTime");
row.Add("EventPoint");
foreach (String key in _indicators.GetKeys())
{
row.Add(key);
}
writer.WriteRow(row);
}
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:11,代码来源:EventPointsIndicatorsFileWriter.cs
示例15: citExpenseTurnoverFee
public citExpenseTurnoverFee(CsvRow row)
{
this.KycrspFundno = Convert.ToInt32(row[0]);
this.FexpRatio = Convert.ToDouble(row[1]);
if (!row[2].Equals("")){
this.FmgmtFee = Convert.ToDouble(row[2]);
}
this.FturnRatio = Convert.ToDouble(row[3]);
this.Ffebegdt = FuncoesAux.StringToDateTime(row[4]);
this.Ffeenddt = FuncoesAux.StringToDateTime(row[5]);
}
开发者ID:MiguelCosta,项目名称:Financas,代码行数:11,代码来源:citExpenseTurnoverFee.cs
示例16: WriteHeader
void WriteHeader(CsvFileWriter writer)
{
CsvRow row = new CsvRow();
row.Add("LongCode");
row.Add("ShortCode");
row.Add("From");
row.Add("To");
row.Add("RangeMax");
row.Add("RangeMin");
writer.WriteRow(row);
}
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:12,代码来源:EventPointsFileWriter.cs
示例17: kToSqlCreateTable
public static void kToSqlCreateTable(string tblsFile, string sqlFile = cSqlCreateTblScriptFile)
{
string tSqlFile = string.Format("{0}k{1}.{2}", cScriptHomePath, sqlFile, cSqlFileExt);
SqlScriptLogger scriptLogger = new SqlScriptLogger(tSqlFile);
scriptLogger.kWriteLine("USE akm_m6dtx;" + Environment.NewLine);
Console.WriteLine(string.Format("Creating {0} . . .", tSqlFile));
string tCsvFile = string.Format("{0}{1}_{2}.{3}", cDataHomePath, tblsFile, cDataPostfix, cCsvFileExt);
CsvFileReader reader = new CsvFileReader(tCsvFile);
Console.WriteLine(string.Format("Opening {0} . . .", tCsvFile));
Console.WriteLine("[Press the ENTER key to begin . . .]");
Console.ReadKey();
CsvRow row = new CsvRow();
bool isHeader = true;
while (reader.ReadRow(row))
{
if (isHeader)
{
isHeader = false;
continue;
}
foreach (string tblSchema in row)
{
string script = string.Empty;
try
{
string tTblSchemaFile = string.Format("{0}_{1}", tblSchema, cSchemaPostfix);
scriptLogger.kWriteLineHeader(tblSchema);
scriptLogger.kWriteLine(2);
scriptLogger.kWriteLine(SqlScriptTrans.kToSqlCreateTable(tTblSchemaFile, string.Format("{0}{1}.{2}", cDataHomePath, tTblSchemaFile, cCsvFileExt)));
scriptLogger.kWriteLine(2);
scriptLogger.kWriteLineFooter();
}
catch (FileNotFoundException)
{
scriptLogger.kWriteLine("## [ERROR::" + tblSchema + "] The table does not exists in the database.");
continue;
}
scriptLogger.kWriteLine(4);
}
}
reader.Close();
scriptLogger.kClose();
}
开发者ID:cgabilla,项目名称:cKarp,代码行数:51,代码来源:SqlScriptGen.cs
示例18: AbrirArchivo
private static CsvFileWriter AbrirArchivo()
{
string filepath = @"C:\Users\Angela\Desktop\estadisticasSimulacion.csv";
CsvFileWriter writer = new CsvFileWriter(@filepath);
//Escribo encabezados de las columnas del archivo
CsvRow header = new CsvRow();
header.Add("Reloj");
header.Add("Promedio clientes en cola");
header.Add("Uso servidor");
header.Add("Clientes atendidos");
header.Add("Demora promedio en cola");
writer.WriteRow(header);
return writer;
}
开发者ID:tinchoabbate,项目名称:SimulacionColaMM1,代码行数:14,代码来源:Program.cs
示例19: CorrData
public CorrData(CsvRow row1, CsvRow row2)
{
Corrout_abs = new double[row1.Count - 1];
distance = new double[row2.Count - 1];
angle = double.Parse(row1[0]);
datatime = DateTime.ParseExact(row2[0], "HH:mm:ss.ff", null);
for (int i = 0; i < row1.Count - 1; i++)
{
Corrout_abs[i] = double.Parse(row1[1 + i]);
}
for (int i = 0; i < row2.Count - 1; i++)
{
distance[i] = double.Parse(row2[1 + i]);
}
}
开发者ID:chenhaoftk,项目名称:bee-corrdata-visualize,代码行数:15,代码来源:CorrData.cs
示例20: CheckBandwidthUsage
private static CsvRow CheckBandwidthUsage(DateTime now)
{
CsvRow row = new CsvRow();
try
{
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
long bytesReceived = 0;
foreach (NetworkInterface inf in interfaces)
{
if (inf.OperationalStatus == OperationalStatus.Up &&
inf.NetworkInterfaceType != NetworkInterfaceType.Loopback &&
inf.NetworkInterfaceType != NetworkInterfaceType.Tunnel &&
inf.NetworkInterfaceType != NetworkInterfaceType.Unknown && !inf.IsReceiveOnly)
{
bytesReceived += inf.GetIPv4Statistics().BytesReceived;
if (row.Count == 0)
{
PhysicalAddress address = inf.GetPhysicalAddress();
byte[] macAddr = address.GetAddressBytes();
string tMac = "";
foreach (byte part in address.GetAddressBytes())
{
tMac += (tMac.Length > 0 ? "-" : "") + (part < 16 ? "0" : "") + part.ToString("X", CultureInfo.InvariantCulture);
}
row.Add(inf.Description);
row.Add(tMac);
}
}
}
if (bytesReceivedPrev == 0)
{
bytesReceivedPrev = bytesReceived;
}
long bytesUsed = bytesReceived - bytesReceivedPrev;
double kBytesUsed = bytesUsed / 1024;
double mBytesUsed = kBytesUsed / 1024;
bytesReceivedPrev = bytesReceived;
row.Add(mBytesUsed.ToString());
row.Add(now.ToString());
row = (mBytesUsed.ToString() == "0") ? null : row;
}
catch (Exception Ex)
{
WriteLog("Log Path :: " + Ex);
}
return row;
}
开发者ID:thirudravidan,项目名称:MySample,代码行数:48,代码来源:networkUsage.cs
注:本文中的CsvRow类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论