导入CSV数据而忽略分隔符 [英] Import of CSV Data ignoring the separator

查看:181
本文介绍了导入CSV数据而忽略分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RStudio,并且想导入csv数据。
此数据有3列,并用,分隔。

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

现在,我键入 test<-read.csv( data1.csv,sep =,)
数据已导入,但仅作为ONE列导入。

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

标题可以,但标题(实际上是3个)也只在一列中组合在一起。

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

如果我设置header = F,则标题为V1。因此,实际上只有一列。
为什么我的分隔符不起作用?

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

推荐答案

尝试从 readr进行 read_csv() 软件包



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)

这篇关于导入CSV数据而忽略分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆