Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在R中读取带有汉字的utf8 csv?_R_Csv - Fatal编程技术网

如何在R中读取带有汉字的utf8 csv?

如何在R中读取带有汉字的utf8 csv?,r,csv,R,Csv,我的系统是win 10,带有R3.5.3和Rstudio 1.1.463,locale如下所示: > Sys.getlocale() [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252" 我的同学给了我一个UT

我的系统是win 10,带有R3.5.3和Rstudio 1.1.463,
locale
如下所示:

> Sys.getlocale()
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252" 
我的同学给了我一个
UTF8
csv文件
sample.csv
在linux系统中生成,可以通过php脚本生成如下:

<?php
$a=
array (
      'col1' => 12,
      'col2' =>  'Y' ,
      'col3' =>  '<p style="text-align: center;">
    <strong style="text-align: center;"><span style="color: rgb(105, 105, 105); font-family: verdana, arial, sans-serif; font-size: 13px;">版权</span></strong></p>
<p>
    <span style="color: rgb(105, 105, 105); font-family: verdana, arial, sans-serif; font-size: 13px;">bla</span></p>
<p>
    <span style="color: rgb(105, 105, 105); font-family: verdana, arial, sans-serif; font-size: 13px;"><img alt="" src="/functions/2.jpg" style="width: 400px; height: 500px;" /></span></p>
<p>
    <span style="color: rgb(105, 105, 105); font-family: verdana, arial, sans-serif; font-size: 13px;">bla</span></p>
' ,
      'col4' =>  '<br />
' );

 $fp = fopen("sample.csv", "wb");

$question_list_cols=array('col1','col2','col3','col4');

fputcsv($fp, $question_list_cols);
if (!fputcsv($fp, array_values($a))) {
        echo "fail<br />";
    }

fclose($fp);
?>


当我在R
dfTry
fileEncoding=“latin1”
中读取
sample.csv
作为
df@TomUdding,已尝试,在read.table(file=file,header=header,sep=sep,quote=quote)中出现错误
1::在read.table的输入连接“sample.csv”中找到无效输入2:(file=file,header=header,sep=sep,quote=quote,:readTableHeader在“sample.csv”上找到的最后一行不完整。
请尝试查看此处()主要是comments@DJV,不起作用。您是否尝试了
df