我有20GB + csv文件,如下所示:
**CallId,MessageNo,Information,Number**
1000,1,a,2
99,2,bs,3
1000,3,g,4
66,2,a,3
20,16,3,b
1000,7,c,4
99,1,lz,4
...
Run Code Online (Sandbox Code Playgroud)
我必须通过CallId和MessageNo将此文件命名为asc.(一种方法是加载数据库 - >排序 - >导出)
如何在不将所有行加载到c#内存的情况下对此文件进行排序?(比如使用streamreader逐行)
你知道一个解决方案库吗?我等你的意见,谢谢
我有4GB +文本文件(csv格式),我想在c#中使用linq处理这个文件.
我在加载csv后运行复杂的linq查询并转换为类?
但是文件大小是4GB,尽管应用程序内存是文件的双倍大小.
我如何处理(linq和新结果)大文件?
谢谢
我使用jquery.load函数动态加载页面,但加载的页面没有绑定到viewModel?
app.js
function viewModel(){
var self = this;
self.users = ko.observable();
Sammy(function() {
this.get("#/users",function() {
$.get("/api/users",function(data){
self.users(data);
});
$("#content").load("pages/users.html");
});
}).run("#/");
}
ko.applyBindings(new viewModel());
Run Code Online (Sandbox Code Playgroud)
index.html的:
<html>
<body>
<div id="content"></div>
<script src="statics/js/lib/jquery-1.8.2.js"></script>
<script src="statics/js/lib/knockout-2.2.0.debug.js"></script>
<script src="statics/js/lib/knockout.mapping.js"></script>
<script src="statics/js/lib/sammy.js"></script>
<script src="statics/js/lib/app.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
页/ users.html
<ul data-bind="foreach: users">
<li><span data-bind="text: fullName"></span></li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我有以下模型:
public interface IUserLookupService {
Guid[] GetDirectChilds(Guid userId);
Guid[] GetAllChilds(Guid userId);
Guid GetDepartment(Guid userId);
}
public interface ICanRefreshCache{
void Refresh();
}
public class XHandler : IEventHandler<UserNameChanged> { ... }
public class YHandler : IEventHandler<TeamCreated> { ... }
public class CachedUserLookupService
: IUserLookupService,
ICanRefreshCache,
IEventHandler<UserNameChanged>
{
private Func<ISession> _sessionFactory;
private IDictionary<Guid, UserInfo> _users = new Dictionary<Guid, UserInfo>();
public CachedUserLookupService(Func<ISession> sessionFactory) {
_sessionFactory = sessionFactory;
}
public void Handle(UserNameChanged ev) {
// change cache with new event parameters
}
public void Refresh() …
Run Code Online (Sandbox Code Playgroud) 我为我的实验用BlockingCollection实现了Producer/Consumer模式.
PerformanceCounter c = null;
void Main()
{
var p =System.Diagnostics.Process.GetCurrentProcess();
c = new PerformanceCounter("Process", "Working Set - Private", p.ProcessName);
(c.RawValue/1024).Dump("start");
var blocking = new BlockingCollection<Hede>();
var t = Task.Factory.StartNew(()=>{
for (int i = 0; i < 10000; i++)
{
blocking.Add(new Hede{
Field = string.Join("",Enumerable.Range(0,100).Select (e => Path.GetRandomFileName()))
});
}
blocking.CompleteAdding();
});
var t2 = Task.Factory.StartNew(()=>{
int x=0;
foreach (var element in blocking.GetConsumingEnumerable())
{
if(x % 1000==0)
{
(c.RawValue/1024).Dump("now");
}
x+=1;
}
});
t.Wait();
t2.Wait();
(c.RawValue/1024).Dump("end");
}
Run Code Online (Sandbox Code Playgroud)
运行后我的内存转储:
start
211908 …
Run Code Online (Sandbox Code Playgroud) 我正在测试此链接上的示例:http://msdn.microsoft.com/en-us/vs11trainingcourse_aspnetmvc4_topic5#_Toc319061802但我有500错误使用WebClient调用另一个控制器.
当我访问"http:// localhost:2323/photo/gallery直接运行,但我正在尝试使用WebClient进行操作时它返回500错误?为什么?"
public ActionResult Index()
{
WebClient client = new WebClient();
var response = client.DownloadString(Url.Action("gallery", "photo", null, Request.Url.Scheme));
var jss = new JavaScriptSerializer();
var result = jss.Deserialize<List<Photo>>(response);
return View(result);
}
Run Code Online (Sandbox Code Playgroud)
由以下异常创建的500错误:
[ArgumentNullException: Value cannot be null.
Parameter name: input]
System.Text.RegularExpressions.Regex.Match(String input) +6411438
Microsoft.VisualStudio.Web.Runtime.Tracing.UserAgentUtilities.GetEurekaVersion(String userAgent) +79
Microsoft.VisualStudio.Web.Runtime.Tracing.UserAgentUtilities.IsRequestFromEureka(String userAgent) +36
Microsoft.VisualStudio.Web.Runtime.Tracing.SelectionMappingExecutionListenerModule.OnBeginRequest(Object sender, EventArgs e) +181
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Run Code Online (Sandbox Code Playgroud)