本文整理汇总了C#中CsvRow.Add方法的典型用法代码示例。如果您正苦于以下问题:C# CsvRow.Add方法的具体用法?C# CsvRow.Add怎么用?C# CsvRow.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvRow
的用法示例。
在下文中一共展示了CsvRow.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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();
}
}
示例3: WriteHeader
void WriteHeader(CsvFileWriter writer)
{
CsvRow row = new CsvRow();
row.Add("Date");
row.Add("KospiRate");
row.Add("KtbRate");
row.Add("DollarRate");
writer.WriteRow(row);
}
示例4: 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);
}
示例5: 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;
}
示例6: 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;
}
示例7: 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));
}
示例8: ToCsv
public void ToCsv()
{
const String kHeader = "CreditPolicyWithMA";
String fileName = String.Format("{0}_{1}.csv", kHeader, DateTime.Now.ToString("yyyy_MM_dd HHmmssfff"));
CsvFileWriter writer = new CsvFileWriter(fileName);
WriteHeader(writer);
foreach (LogRow log in _logs)
{
CsvRow row = new CsvRow();
row.Add(log.CurDate.ToString("yyyy-MM-dd"));
row.Add(log.KospiWeight.ToString());
writer.WriteRow(row);
}
writer.Close();
}
示例9: writePlayers
public void writePlayers(List<Player> listPlayers)
{
using (CsvFileWriter writer = new CsvFileWriter(file))
{
foreach (var item in listPlayers)
{
CsvRow row = new CsvRow();
row.Add(item.Name);
for (int i = 0; i < Constants.RaceNumber; i++)
{
row.Add(item.Races[i].ToString());
row.Add(item.Victory[i].ToString());
row.Add(item.Defeat[i].ToString());
row.Add(item.Elo[i].ToString());
}
writer.WriteRow(row);
}
}
}
示例10: WriteBody
void WriteBody(CsvFileWriter writer)
{
List<EventPoint> eps = _eventPoints.EventPoints;
Dictionary<String, List<DateTimeDoublePair>> indicators = _indicators.GetIndicators(_targetDate);
for (int i = 0; i < eps.Count; i = i + 2)
{
EventPoint ep = eps[i];
CsvRow row = new CsvRow();
row.Add(ep.DateTimeFrom.ToString("yyyy-MM-dd HH:mm:ss.fff"));
row.Add(ep.RangeMax.ToString("n"));
foreach (List<DateTimeDoublePair> pair in indicators.Values.ToList())
{
row.Add(pair[i].DoubleValue.ToString("n"));
Trace.Assert(pair[i].DateTimeValue == ep.DateTimeFrom);
}
writer.WriteRow(row);
}
}
示例11: 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);
}
示例12: WriteBody
void WriteBody(CsvFileWriter writer, List<EventPoint> eventPoints)
{
foreach (EventPoint ep in eventPoints)
{
CsvRow row = new CsvRow();
row.Add(ep.LongCode);
row.Add(ep.ShortCode);
row.Add(ep.DateTimeFrom.ToString("yyyy-MM-dd HH:mm:ss.fff"));
row.Add(ep.DateTimeTo.ToString("yyyy-MM-dd HH:mm:ss.fff"));
row.Add(ep.RangeMax.ToString("n1"));
row.Add(ep.RangeMin.ToString("n1"));
writer.WriteRow(row);
}
}
示例13: ReadRow
/// <summary>
/// Reads a row of data from a CSV file
/// </summary>
/// <param name="row"></param>
/// <returns></returns>
public bool ReadRow(CsvRow row)
{
row.LineText = ReadLine();
if (String.IsNullOrEmpty(row.LineText))
return false;
int pos = 0;
int rows = 0;
while (pos < row.LineText.Length)
{
string value;
// Parse unquoted value
int start = pos;
while (pos < row.LineText.Length && row.LineText[pos] != ',')
pos++;
value = row.LineText.Substring(start, pos - start);
// Add field to list
if (rows < row.Count)
row[rows] = value;
else
row.Add(value);
rows++;
// Eat up to and including next comma
while (pos < row.LineText.Length && row.LineText[pos] != ',')
pos++;
if (pos < row.LineText.Length)
pos++;
}
// Delete any unused items
while (row.Count > rows)
row.RemoveAt(rows);
// Return true if any columns read
return (row.Count > 0);
}
示例14: WriteGeoRoutes
private static void WriteGeoRoutes()
{
if (routes_Filename != null)
{
using (CsvFileWriter writer = new CsvFileWriter(routes_Filename))
{
int routeID = 0;
foreach (Route r in MapTools.routes.Values)
{
{
foreach (Waypoint w in r.waypoints)
{
CsvRow row = new CsvRow();
// row.Add(trip.id.ToString());
// row.Add(trip.startTime.ToString());
row.Add(routeID.ToString());
row.Add(w.Lat.ToString());
row.Add(w.Lng.ToString());
row.Add(w.elapse.ToString());
row.Add(w.distance.ToString());
row.Add(w.Address);
writer.WriteRow(row);
}
}
routeID++;
}
}
}
}
示例15: WriteGeoLocationNames
private static void WriteGeoLocationNames()
{
if (locationNames_Filename != null)
{
using (CsvFileWriter writer = new CsvFileWriter(locationNames_Filename))
{
foreach (string key in MapTools.locationNames.Keys)
{
string name = MapTools.locationNames[key];
CsvRow row = new CsvRow();
// row.Add(trip.id.ToString());
// row.Add(trip.startTime.ToString());
row.Add(key);
row.Add(name);
writer.WriteRow(row);
}
}
}
}