Import of CSV Data ignoring the separator

僤鯓⒐⒋嵵緔 提交于 2019-12-16 18:04:42

问题


I'm using RStudio and I wanted to import csv data. This data has 3 columns and they are separated by ",".

Now I type test <- read.csv("data1.csv", sep=",") Data is imported but its imported as just ONE column.

Headers are okay, but also the headers (actually 3) are combined together in just one column.

If I set header=F, there was V1 as heading. So there really is just one column. Why is my separator not working?


回答1:


try read_csv() from readr package

install.packages("devtools")
devtools::install_github("hadley/readr")

with your sample input

library(readr)
file <- 'Alter.des.Hauses,"Quadratfuß","Marktwert"\n33,1.812,"$90.000,00"\n'
read_csv(file) # for the actual use read_csv("file.csv") ...
read_csv2(file)


来源:https://stackoverflow.com/questions/30142183/import-of-csv-data-ignoring-the-separator

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