如何解決 read.csv “輸入連結 ‘test.csv’ 中的輸入不正確” 問題?

208 views
Skip to first unread message

Jiun-Jung Lin

unread,
Jul 21, 2020, 6:26:38 AM7/21/20
to R軟體使用者論壇
小弟有幾個csv檔案需要使用ggplot進行分析,但不幸遇到一些警告訊息,但一直找不到解決方法
檔案執行read.csv那行就出現以下訊息:
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  輸入連結 '../snownlp-master/test_01_se_value.csv' 中的輸入不正確
2: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  incomplete final line found by readTableHeader on '../snownlp-master/test_01_se_value.csv'

如下圖:
messageImage_1595326465302.jpg










以上訊息一直帶給困擾,我無法成功解決這個問題,我也有查過裡面的資料確實是 ‘utf-8’ 編碼,以及嘗試過使用大寫 ‘UTF-8’ 執行,甚至在編碼部分改為寫 Encoding = 'utf-8'或 Encoding = 'UTF-8'

此外,我打開RStudio的表格查看時發現它只有出現一筆資料,但我在pandas卻看到完整的資料,如下圖:

messageImage_1595326776032.jpg










👆R

messageImage_1595326962062.jpg































👆Pandas

我想知道問題是在哪裡?希望大家能幫到我,謝謝。

Yan-Ru YU

unread,
Jul 22, 2020, 7:21:00 AM7/22/20
to R軟體使用者論壇
Hi,
讀utf8的檔案,我個人常用的解決方案提供給你參考:

1. 下載notepad++,將檔案讀入後將編碼更改為ansi,再重新以encoding=“ansi”讀進R試試。

2. Try read.table(“file”,sep=“,”,fileEncoding=“utf8”,...)

WEPA ^_^

unread,
Apr 24, 2025, 8:45:05 AMApr 24
to R軟體使用者論壇
參考以下文章:

R讀取中文檔案產生亂碼等錯誤問題

Yan-Ru YU 在 2020年7月22日 星期三晚上7:21:00 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages