M
M
Mikhail012017-03-02 13:03:59
data mining
Mikhail01, 2017-03-02 13:03:59

How to properly import csv file into RStudio?

In general, I looked on the Internet at the forums. Already tried everything. And change the encoding. But the errors are not corrected.
Please help me understand what is wrong. Below are the codes for the various options.
> 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:
package 'readr' was built under R version 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:
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

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question