@Mikhail01

Как правильно импортировать файл csv в RStudio?

В общем посмотрел в Интернете на форумах. Всё уже перепробовал. И кодировку менять. Но ошибки не исправляются.
Помогите пожалуйста понять что не так. Ниже привожу коды различных вариантов.

> a <- read.csv(file = "air.csv", header = TRUE)
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to contain embedded nulls
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 4 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'air.csv'

> a<-read.table(file = "air.csv", header = TRUE, sep = ",")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 1 did not have 2 elements
In addition: Warning messages:
1: In read.table(file = "air.csv", header = TRUE, sep = ",") :
line 1 appears to contain embedded nulls
2: In read.table(file = "air.csv", header = TRUE, sep = ",") :
line 4 appears to contain embedded nulls
3: In read.table(file = "air.csv", header = TRUE, sep = ",") :
incomplete final line found by readTableHeader on 'air.csv'

> a = read.csv(file = "air.csv",header = TRUE)
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to contain embedded nulls
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 4 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'air.csv'

> a <- read.csv("air.csv", sep = ",", fileEncoding = "utf-16")
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
invalid input found on input connection 'air.csv'
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'air.csv'

> Sys.getlocale()
[1] "LC_COLLATE=Russian_Russia.1251;LC_CTYPE=Russian_Russia.1251;LC_MONETARY=Russian_Russia.1251;LC_NUMERIC=C;LC_TIME=Russian_Russia.1251"
> a <- read.csv("air.csv", fileEncoding = "UTF8")
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
invalid input found on input connection 'air.csv'
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'air.csv'

> library(readr)
Warning message:
пакет ‘readr’ был собран под R версии 3.2.5
> air <- read_csv("C:/air.csv", col_types = cols_only(`PK\003\004\024` = col_character()))
Warning: 5556 parsing failures.
row col expected actual
2 NA 1 columns 2 columns
3 PK embedded null
3 NA 1 columns 3 columns
7 PK embedded null
7 NA 1 columns 2 columns
... .............. ......... .............
See problems(...) for more details.

> View(air)

> a <- data.table(read.table(air.csv, header = FALSE, sep = ",",
+ comment.char = "", fill = TRUE, check.names = FALSE,
+ blank.lines.skip = TRUE))
Error: could not find function "data.table"

> a <- data.table(read.table("air.csv", header = FALSE, sep = ",",
+ + comment.char = "", fill = TRUE, check.names = FALSE,
Error: unexpected '=' in:
"a <- data.table(read.table("air.csv", header = FALSE, sep = ",",
+ comment.char ="
> + blank.lines.skip = TRUE))
Error: unexpected ')' in " + blank.lines.skip = TRUE)"
> df <- read.table("air.dat", header = T).
Error: unexpected symbol in "df <- read.table("air.dat", header = T)."

Date Time CO(GT) PT08.S1(CO) NMHC(GT) C6H6(GT) PT08.S2(NMHC) NOx(GT) PT08.S3(NOx) NO2(GT) PT08.S4(NO2) PT08.S5(O3) T RH AH
10.03.2004 18:00:00 2,6 1360 150 11,9 1046 166 1056 113 1692 1268 13,6 48,9 0,7578
10.03.2004 19:00:00 2 1292 112 9,4 955 103 1174 92 1559 97
  • Вопрос задан
  • 1289 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы