Error in scan while attempting to load a dataset

Hi guys,
While trying to load a dataset i get the error below. Where might I be going wrong??

data=read.table('ODI_2002-2011.csv', header = T, sep = ',')
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
line 29 did not have 35 elements

Hello,

You might likely have missing or blanks for some and that is causing trouble for the file. Specifically look at line 29 of your file. Happy to check for you directly if you can share data.

For you to get read.table to work you will need fill = TRUE. The problem however is that it will still struggle to parse the file correctly as it ends up with 242197 observations x 34 variables. When we look at the file we are expected to see 649925 observations x 34 which read_csv and read_delim achieves. I would rather use either instead of read.table here in this instance.

data = read.table("ODI 2002-2011.csv", header = TRUE, fill = TRUE, sep = ',')

library(readr)

df <- read_csv("ODI 2002-2011.csv")

df2 <- read_delim("ODI 2002-2011.csv", delim = ",", col_names = TRUE)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Thank you for taking the time.
Please find attached a link to get the dataset.

https://www.osha.gov/odi/ODI2002-2011.zip

regards.