我正在尝试读取需要使用 ANSI 编码读取的 csv/文本文件。然而这不起作用。有任何想法吗?
\n\nmainDF= spark.read.format("csv")\\\n .option("encoding","ANSI")\\\n .option("header","true")\\\n .option("maxRowsInMemory",1000)\\\n .option("inferSchema","false")\\\n .option("delimiter", "\xc2\xac")\\\n .load(path)\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\njava.nio.charset.UnsupportedCharsetException:ANSI
\n
该文件超过 5GB,因此需要 Spark。
\n\n我也尝试过小写的 ANSI
\n我正在尝试遍历数据框并连接由 Rcpp 中的空格分隔的字块。
我尝试阅读 Stack Overflow 上的一些答案,但对 Rcpp 中字符串的连接方式感到非常困惑。(例如用 Rcpp 连接 StringVector)
我知道在 C++ 中你可以只使用 + 运算符来添加字符串。
这是我下面的 Rcpp 函数
cppFunction('
Rcpp::StringVector formTextBlocks(DataFrame frame) {
#include <string>
using namespace Rcpp;
NumericVector frame_x = as<NumericVector>(frame["x"]);
LogicalVector space = as<LogicalVector>(frame["space"]);
Rcpp::StringVector text=as<StringVector>(frame["text"]);
if (text.size() == 0) {
return text;
}
int dfSize = text.size();
for(int i = 0; i < dfSize; ++i) {
if ( i !=dfSize ) {
if (space[i]==true) {
text[i]=text[i] + text[i+1] ;
}
}
}
return …Run Code Online (Sandbox Code Playgroud)