CSV import problem on R

im a newbie and im trying to get to work with Rstudio for my thesis and i can not import my .csv file to R. i tried this code but it didnt work

dok<-read.csv("data_preprocessing_test1a.csv" , header = TRUE, stringsAsFactors = TRUE, sep = ",", fileEncoding = "UTF-16LE", dec = ".")

and the following error

Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  invalid input found on input connection 'data_preprocessing_test1a.csv'
2: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  incomplete final line found by readTableHeader on 'data_preprocessing_test1a.csv'

i hope everybody can help, thank you in advance!

Hi @captaonmarvel,
Welcome to the RStudio Community Forum.

Can you post a sample from the top of your .csv data file? That way we can make a reproducible example to try and solve the problem. Please read the posting guide about how to do this (and please don't use a screenshot).

this is the .csv data that i uploaded on gdrive

csv data

Hi @captaonmarvel,
The first column of text in your file contains many comma "," symbols which will totally confuse the read.csv() because you have specified the field separator character also as ",".
Your data looks like its in a spreadsheet; Microsoft Excel maybe? If so, I suggest you read directly from the Excel file, something like this:

dok <- read_excel(path="data_preprocessing_test1a.xlsx" ,
                  col_names= TRUE)


ahhh it worked, thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.