CSV load error with monetdb & R

为君一笑 提交于 2019-12-11 11:08:59

问题


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?



来源:https://stackoverflow.com/questions/21779280/csv-load-error-with-monetdb-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!