Read csv file in R with double quotes

前端 未结 3 464
借酒劲吻你
借酒劲吻你 2021-01-17 22:36

Suppose I have a csv file looks like this:

Type,ID,NAME,CONTENT,RESPONSE,GRADE,SOURCE
A,3,\"\",\"I have comma, ha!\",I have open double quotes\",A,\"\"
         


        
3条回答
  •  清歌不尽
    2021-01-17 23:18

    fread from data.table handles this just fine:

    library(data.table)
    
    fread('Type,ID,NAME,CONTENT,RESPONSE,GRADE,SOURCE
    A,3,"","I have comma, ha!",I have open double quotes",A,""')
    #   Type ID NAME           CONTENT                   RESPONSE GRADE SOURCE
    #1:    A  3      I have comma, ha! I have open double quotes"     A       
    

提交回复
热议问题