2017-05-25 79 views
0

之间的数据我有一个包含数据和信息的CSV文件。信息在{}之间提供。文件的内容是这种格式。如何删除paranthesis

{information} 
data 
{information} 

如何删除信息,并从文件中提取数据文件的

结构

Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 8586 obs. of 1 variable: 
$ {: chr "Data Vers : 7" "WinDate : 27.10.2016" "WinTime : 16:28:31" 
"VecTime : 265426.631" ... 
- attr(*, "spec")=List of 2 
..$ cols :List of 1 
.. ..$ {: list() 
.. .. ..- attr(*, "class")= chr "collector_character" "collector" 
..$ default: list() 
.. ..- attr(*, "class")= chr "collector_guess" "collector" 
..- attr(*, "class")= chr "col_spec" 

数据看起来像这样

{ 
    properties of data 
    } 
    x  y  z 
    1.2  4.6 5.4 
    3.5  2.7 6.8 
    { 
    properties of data 
    } 

请指导我关于这个

+1

请问您可以使用'dput'显示数据的几行 – akrun

+0

对不起,我无法提供数据。 – user821

+0

我们不要求提供整个数据集,但至少需要一两行。如果我们没有一个轻微的图片,我们不能帮助!使用头(数据),然后复制粘贴前两行。 –

回答

0

这是一个解决方案:

library(stringr) 
provided_csv<-c("{information} 
data_1 
{information}","{information} 
       data_2 
       {information}") 
str_match(provided_csv,"\\{(.*?)\\}")[,2] 
[1] "information" "information" 
+0

我已经使用read.CSV加载了该文件并尝试了您的代码。我正在拿NA。我必须删除信息 – user821

+1

我坚信您必须在将数据添加到R之前修复数据。确保您的源以正确的格式向您提供它们! –