In read.table(): incomplete final line found by readTableHeader

前端 未结 7 2027
谎友^
谎友^ 2020-12-29 21:58

I have a CSV when I try to read.csv() that file, I get the warning warning message:

In read.table(file = file, header = header, sep = sep, quote         


        
7条回答
  •  一生所求
    2020-12-29 22:47

    This is not a CSV file, each line is a column, you can parse it manually, e.g.:

    file <- '~/Downloads/PING CONCOURS DONNES.csv'
    lines <- readLines(file)
    columns <- strsplit(lines, ';')
    headers <- sapply(columns, '[[', 1)
    data <- lapply(columns, '[', -1)
    df <- do.call(cbind, data)
    colnames(df) <- headers
    print(head(df))
    

    Note that you can ignore the warning, due that the last end-of-line is missing.

提交回复
热议问题