本文整理汇总了C#中List.ToCsv方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToCsv方法的具体用法?C# List.ToCsv怎么用?C# List.ToCsv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.ToCsv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Go
internal static void Go()
{
var filePath = @"e:\bondsToAddIfNotThere.csv";
var fieldList = new[] {"ID_ISIN", "TICKER"};
var results = new List<ResultClass>();
var strB = new StringBuilder();
foreach (var line in CsvFile.Read<IdClass>(filePath))
{
var refData = BbgTalk.HistoryRequester.GetReferenceData(line.Id, fieldList, null);
results.Add(new ResultClass()
{
ISIN=refData.GetValue<string>("ID_ISIN"),
Market=refData.GetValue<string>("TICKER"),
});
strB.Append(refData.GetValue<string>("ID_ISIN")).Append(" ");
}
Logger.Debug(strB.ToString(), typeof (AddBondsFromBbgList));
results.ToCsv(@"e:\bondsToAddIsins.csv");
}
示例2: Go2
public static void Go2()
{
var yearOfFile = 2015;
var ricList = new[] { "ED", "FEI", "FGBL", "FGBM", "FGBS", "FGBS", "TY", "FLG", "FSS", "FGB", "FBTP", "FOAT" };
var contractMonths = new[] { MonthCode.H, MonthCode.M, MonthCode.N, MonthCode.Q, MonthCode.U, MonthCode.V, MonthCode.X, MonthCode.Z };
contractMonths = (MonthCode[])Enum.GetValues(typeof(MonthCode));
var processedDir = @"E:\futuresData\Processed";
var markDir = @"e:\futuresData\MarkEllis2";
foreach (var ricStart in ricList)
{
foreach (var contractYear in new[] { 2015, 2016, 2017 })
{
foreach (var monthOfFile in new[] { 6, 7 })
{
foreach (var contractMonth in contractMonths)
{
var searchString = string.Format("*{0}-{1}-{2}{3}{4}.csv", yearOfFile, monthOfFile.ToString("00"), ricStart, contractMonth, contractYear - 2010);
var files = Directory.GetFiles(processedDir, searchString);
if (files.Length == 0)
continue;
var list = new List<FuturesIntradaySaver.FuturesLineItem>();
foreach (var item in CsvFile.Read<FuturesIntradaySaver.FuturesLineItem>(files[0]))
{
if (item.gmtDate.HasValue && (item.gmtDate.Value.Minute == 32 || item.gmtDate.Value.Minute == 2))
{
item.Date = TimeZoneHelper.ConvertGmtTimeToLondon(item.gmtDate.Value);
item.Time = string.Empty;
if (item.Date.Hour < 8)
continue;
if (item.Date.Hour > 17)
continue;
list.Add(item);
}
}
list.ToCsv(string.Join("\\", markDir,
string.Format("{0}-{1}-{2}{3}{4}", yearOfFile, monthOfFile.ToString("00"), UpdateStaticDataForFutures.MAPS[ricStart].Item1, contractMonth, contractYear - 2010)));
}
}
}
}
}
示例3: DeleteExcept
public void DeleteExcept(List<int> helpIds)
{
if (null == helpIds || helpIds.Count == 0)
return;
using (var connection = SqlConnectionFactory.GetConnection())
using (var command = connection.CreateCommand())
{
command.CommandType = CommandType.Text;
command.CommandText = SqlScripts.FirstTimeHelp_DeleteExcept.Replace("@pageIds", helpIds.ToCsv());
connection.Open();
command.ExecuteNonQuery();
}
}
示例4: RunSimulations
private static void RunSimulations(ProgramOptions options)
{
TimeSpan ts = new TimeSpan(365 * options.Years, 0, 0, 0);
ts = new TimeSpan(ts.Ticks / options.Steps); // note that ts.TotalDays / 365.0 <=> t / n
Random rnd = new Random(options.Seed);
List<StockEstimate> paths = new List<StockEstimate>();
for (int i = 0; i < options.Count; ++i)
{
PathSimulate(options, ts, rnd, paths);
}
File.WriteAllText("output.txt", paths.ToCsv());
PrintEndInfo(options, paths);
}
示例5: Export
private void Export()
{
if (_salesPendingExport.Any())
{
var orders = _salesPendingExport.Select(OrderExportHelper.MapSalesExport).ToList();
var orderToCsv = new List<ExportSaleItem>();
foreach (var order in orders)
{
orderToCsv.AddRange(order);
}
var outputFileDescription = new CsvFileDescription
{
// cool - I can specify my own separator!
SeparatorChar = ',',
FirstLineHasColumnNames =
false,
QuoteAllFields = true,
EnforceCsvColumnAttribute =
true
};
try
{
Messenger.Default.Send(DateTime.Now.ToString("hh:mm:ss") + " Attempting to export {0} sales", orders.Count);
//var cc = new CsvContext();
//cc.Write(orderToCsv, OrderExportHelper.GetExportFileName("AllSales"), outputFileDescription);
DumpExportFilesAsync(orderToCsv.ToCsv(),OrderExportHelper.GetExportFileName("AllSales"));
_salesPendingExport.OrderBy(p => p.GenericOrderReference).Distinct().ToList().ForEach(
OrderExportHelper.MarkAsExported);
Messenger.Default.Send(DateTime.Now.ToString("hh:mm:ss") + string.Format(" Export compeleted for={0} sales", orders.Count));
_salesPendingExport.Clear();
}
catch (Exception ex)
{
Messenger.Default.Send(DateTime.Now.ToString("hh:mm:ss") + "Error occured while exporting..See error logs for details");
FileUtility.LogError(ex.Message);
}
}
else
{
Messenger.Default.Send(DateTime.Now.ToString("hh:mm:ss") + " No sales exported");
}
}
示例6: Main
static void Main(string[] args)
{
//ConsoleClient d = new ConsoleClient();
//d.Start();
Client client = new Client();
// /Search/Motors/Used.xml?Make=Honda&Model=Jazz
// /Search/Motors/Used.xml?make=Honda&model=Jazz
var tmp = client.SearchUsedMotors("/Search/Motors/Used.xml?Make=Honda&Model=Jazz");
var totalCount = tmp.TotalCount;
var cars = new List<Car>();
int page = 1;
while (cars.Count < totalCount)
{
string query = string.Format("/Search/Motors/Used.xml?Make=Honda&Model=Jazz&page={0}", page);
cars.AddRange(client.SearchUsedMotors(query).List);
page++;
}
//car.ListingId 703207653 int
//car.Year 2006 int
//car.Odometer
//car.Model "Fit / Jazz LOW KM" string
//car.EngineSize 1300 int
//car.PriceDisplay
//car.Transmission "Automatic" string
//car.StereoDescription "CD(s), Stereo" string
//car.Doors 5 int
//car.BodyStyle "Hatchback" string
//car.IsDealer true bool
//car.Region "Auckland" string
//car.BuyNowPrice 0 decimal
//car.BuyNowPriceSpecified
//car.IsReserveMet true bool
//car.IsNew false bool
//car.BidCount 32 int
cars.ToCsv("data.csv");
}
示例7: RecoverManySuspendedTickets
public bool RecoverManySuspendedTickets(List<long> ids)
{
var resource = string.Format("suspended_tickets/recover_many.json?ids={0}", ids.ToCsv());
var res = RunRequest(resource, "PUT");
return res.HttpStatusCode == HttpStatusCode.OK;
}
示例8: DeleteMultiple
public bool DeleteMultiple(List<long> ids)
{
return GenericDelete(string.Format("{0}/destroy_many.json?ids={1}", _tickets, ids.ToCsv()));
}
示例9: RunQuery
public void RunQuery()
{
ValidateQuery();
var leanKitAuth = new LeanKitBasicAuth
{
Hostname = _args.Host,
Username = _args.User,
Password = _args.Password
};
// For internal development testing
if (_args.Host.Equals("kanban-cibuild", StringComparison.InvariantCultureIgnoreCase))
leanKitAuth.UrlTemplateOverride = "http://{0}.localkanban.com";
WriteInfo("Connecting to LeanKit account...");
var api = new LeanKitClientFactory().Create(leanKitAuth);
if (_args.Boards)
{
WriteInfo("Getting all boards...");
var boards = api.GetBoards();
var boardList = boards.Select(Mapper.Map<BoardLiteView>);
var output = _args.Csv ? boardList.ToCsv() : _args.Json ? boardList.ToJson() : boardList.Dump();
Console.WriteLine(output);
}
else if (_args.Board > 0)
{
WriteInfo(string.Format("Getting board [{0}]...", _args.Board));
var board = api.GetBoard(_args.Board);
if (_args.Lanes || _args.Lane > 0 || _args.Cards)
{
// Get lanes
var boardLanes = new List<Lane>();
if (_args.Lane > 0)
{
WriteInfo(string.Format("Getting lane [{0}]...", _args.Lane));
boardLanes.AddRange(board.AllLanes().Where(lane => lane.Id == _args.Lane));
}
else
{
if (_args.IncludeBacklog) boardLanes.AddRange(board.Backlog);
boardLanes.AddRange(board.Lanes);
if (_args.IncludeArchive) boardLanes.AddRange(board.Archive);
}
if (_args.Cards)
{
WriteInfo("Getting cards...");
var cards = new List<MappedCardView>();
foreach (var lane in boardLanes)
{
cards.AddRange(lane.Cards.Select(Mapper.Map<MappedCardView>));
}
// Archived cards is a separate API call
if (_args.IncludeArchive)
{
var archivedCards = api.GetArchiveCards(_args.Board);
cards.AddRange(archivedCards.Select(Mapper.Map<MappedCardView>));
}
var output = _args.Csv ? cards.ToCsv() : _args.Json ? cards.ToJson() : cards.Dump();
Console.WriteLine(output);
}
else
{
var lanes = boardLanes.Select(Mapper.Map<LaneView>);
var output = _args.Csv ? lanes.ToCsv() : _args.Json ? lanes.ToJson() : lanes.Dump();
Console.WriteLine(output);
}
}
else
{
var boardView = Mapper.Map<BoardView>(board);
var output = _args.Csv ? boardView.ToCsv() : _args.Json ? boardView.ToJson() : boardView.Dump();
Console.WriteLine(output);
}
}
}
示例10: RecoverManySuspendedTicketsAsync
public async Task<bool> RecoverManySuspendedTicketsAsync(List<long> ids)
{
var resource = string.Format("suspended_tickets/recover_many.json?ids={0}", ids.ToCsv());
var res = RunRequestAsync(resource, "PUT");
return await res.ContinueWith(x => x.Result.HttpStatusCode == HttpStatusCode.OK);
}
示例11: GetMultipleTickets
public GroupTicketResponse GetMultipleTickets(List<long> ids)
{
return GenericGet<GroupTicketResponse>(string.Format("{0}/show_many?ids={1}.json", _tickets, ids.ToCsv()));
}
示例12: MapTransactionResponse
private TransactionResponse MapTransactionResponse(List<ShellOrderExportDto> orders)
{
var response = new TransactionResponse();
if(orders==null ||!orders.Any())
{
response.ErrorInfo = "Success";
response.Result = "Order not found";
response.ResultInfo = "No transaction to export";
return response;
}
response.TransactionData = orders.ToCsv();
return response;
}
示例13: BulkUpdateAsync
public async Task<JobStatusResponse> BulkUpdateAsync(List<long> ids, BulkUpdate info)
{
var body = new { ticket = info };
return await GenericPutAsync<JobStatusResponse>(string.Format("{0}/update_many.json?ids={1}", _tickets, ids.ToCsv()), body);
}
示例14: GetViewCounts
public GroupViewCountResponse GetViewCounts(List<long> viewIds)
{
return GenericGet<GroupViewCountResponse>(string.Format("views/count_many.json?ids={0}", viewIds.ToCsv()));
}
示例15: GetMultipleTopicsByIdAsync
public async Task<GroupTopicResponse> GetMultipleTopicsByIdAsync(List<long> topicIds)
{
return await GenericPostAsync<GroupTopicResponse>(string.Format("topics/show_many?ids={0}.json", topicIds.ToCsv()));
}