我正在以下while语句中逐行读取StreamReader中的数据.
while (!sr.EndOfStream)
{
string[] rows = sr.ReadLine().Split(sep);
int incr = 0;
foreach (var item in rows)
{
if (item == "NA" | item == "" | item == "NULL" | string.IsNullOrEmpty(item) | string.IsNullOrWhiteSpace(item))
{
rows[incr] = null;
}
++incr;
}
// another logic ...
}
Run Code Online (Sandbox Code Playgroud)
代码工作正常,但由于巨大的csv文件(500,000,000行和数百列),它非常慢.有没有更快的方法来检查数据(如果它是"NA","",......应该被替换为null).目前我正在使用带有incr变量的foreach来更新foreach中的项目.
我想知道linq或lambda会更快但我在这些方面很新.
我正在尝试使用 shell 命令从 R 运行简单的外部应用程序。
shell('"C:\\Program Files\\SomeApp\\bin\\Release\\SomeApp.exe" "C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\" "1" "yes"')
Run Code Online (Sandbox Code Playgroud)
如果我从命令行运行括号中的部分,它可以完美运行。但是如果我通过 R 的 shell 命令运行它,它会抛出一个错误:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c "C:\Program Files\SomeApp\bin\Release\SomeApp.exe" "C:\Users\SomeUser\R_Scripts\RProjects\Rprojects\" "1" "yes"' had status 1
2: In shell("\"C:\\Program Files\\SomeApp\\bin\\Release\\SomeApp.exe\" \"C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\\" \"1\" \"yes\"") :
'"C:\Program Files\SomeApp\bin\Release\SomeApp.exe" "C:\Users\SomeUser\R_Scripts\RProjects\Rprojects\" "1" "yes"' execution failed with error code 1
Run Code Online (Sandbox Code Playgroud)
有没有其他人面临同样的问题?