从基于模式的大字符串中提取文本

时间:2016-03-20 16:13:46

标签: regex r string pattern-matching strsplit

我有一大串字符,并希望从匹配模式中提取某些信息:

str(input) chr [1:109094] "{'asin': '0981850006', 'description': 'Steven Raichlen\'s Best of Barbecue Primal Grill DVD. The first three volumes of the si"| truncated ...

我得到以下input[1]的内容 - 产品元素描述

[1] ("{'asin': '144072007X', 'related': {'also_viewed': ['B008WC0X0A', 'B000CPMOVG', 'B0046641AE', 'B00J150GAO', 'B00005AMCG', 'B005WGX97I'], 
         'bought_together': ['B000H85WSA']}, 
         'title': 'Sand Shark Margare Maron Audio CD', 
         'price': 577.15, 
         'salesRank': {'Patio, Lawn & Garden': 188289}, 
         'imUrl': 'http://ecx.images-amazon.com/images/I/31B9X0S6dqL._SX300_.jpg', 
         'brand': 'Tesoro', 
         'categories': [['Patio, Lawn & Garden', 'Lawn Mowers & Outdoor Power Tools', 'Metal Detectors']], 
'description': \"The Tesoro Sand Shark metal combines time-proven PI circuits with the latest digital technology creating the first.\"}") 

现在我想迭代大字符串的每个元素并提取asintitlepricesalesRankbrand和{{ 1}}应该保存在data.frame中以便更好地处理。

您可能会注意到,数据最初来自JSON文件。我尝试使用categories命令导入它,但它没有帮助。所以只需使用stream_in导入它。请帮忙!有点绝望......任何提示都很受欢迎!

readLines包显示以下问题:

jsonlite

有关于此的任何新想法吗? 鉴于有关该问题的许多未解答的问题,必须与新手非常相关;)

0 个答案:

没有答案
相关问题