CSV load error with monetdb & R

2019-08-10 22:20发布

问题:

I'm trying to load various CSVs into monetdb, using R and RStudio but I get the error below. This is the code (code tested with the iris dataset & generally working fine) and the error message:

> monetdb.read.csv(conn,fnamed,nrows=nrows,header=TRUE,tablename=tabled,delim=",")

/Users/Enzo/NHS/data/sha_lookup.csv /Users/Enzo/NHS/data/sha_lookup.csv 
Error in .local(conn, statement, ...) : 
  Unable to execute statement 'copy 12 offset 2 records into sha_lookup from '/Users/Enzo/NHS/data/sh...'.
Server says '!failed to import table'.

The file I'm trying to load is a short and simple csv:

    SHA,SHAname
    Q30,NORTH EAST STRATEGIC HEALTH AUTHORITY
    Q31,NORTH WEST STRATEGIC HEALTH AUTHORITY
    Q32,YORKSHIRE AND THE HUMBER STRATEGIC HEALTH AUTHORITY
    Q33,EAST MIDLANDS STRATEGIC HEALTH AUTHORITY
    Q34,WEST MIDLANDS STRATEGIC HEALTH AUTHORITY
    Q35,EAST OF ENGLAND STRATEGIC HEALTH AUTHORITY
    Q36,LONDON STRATEGIC HEALTH AUTHORITY
    Q37,SOUTH EAST COAST STRATEGIC HEALTH AUTHORITY
    Q38,SOUTH CENTRAL STRATEGIC HEALTH AUTHORITY
    Q39,SOUTH WEST STRATEGIC HEALTH AUTHORITY

RStudio reads the above CSV file with no issues. More importantly I can read this CSV into a R dataframe with read.csv, then write a CSV file with write.table. Now I can load this "new" CSV into monetdb using the code above with no problem.

Please note that I tried to edit the file using quotes "" everywhere to see if that was the problem, but I still got the error.

回答1:

Does your original file have Windows-style line endings?



标签: r monetdb