I am new to R. I am trying to learn basic data I/o and preprocessing. I have a text file of the format given below. It is a non standard format (unlike CSV,JSON etc) I need to convert the following structure into a table like format (more precisely a dataframe that we obtain from csv files)
Input
product/productId: B000H13270
review/userId: A3J6I70Z9Q0HRX
review/profileName: Lindey H. Magee
review/helpfulness: 1/3
review/score: 5.0
review/time: 1261785600
review/summary: it's fabulous, but *not* from amazon!
review/text: the price on this product certainly raises my attention on compairing amazon price with the local stores. i can get a can of this rotel at my local kroger for $1. dissapointing!
product/productId: B000H13270
review/userId: A1YLOZQKBX3J1S
review/profileName: R. Lee Dailey "Lee_Dailey"
review/helpfulness: 1/4
review/score: 3.0
review/time: 1221177600
review/summary: too expensive
review/text: howdy y'all,<br /><br />the actual product is VERY good - i'd rate the item a 4 on it's own. however, it's only ONE dollar at the local grocery and - @ twenty eight+ dollars per twelve pack - these are running almost two and a half dollars each.<br /><br />as i said, TOO EXPENSIVE. [*sigh ...*] i was really hoping to get them at something approaching the local cost.<br /><br />take care,<br />lee
Output
product/productId | review/UserId ......... | review/text
B000H13270 |A3J6I70Z9Q0HRX | the price on this .... dissapointing!
B000H13270 | A1YLOZQKBX3J1S |howdy y'all,<br /> ..... lee
In Python
I could have performed the same in the following manner
dataFile = open('filename').read().split('\n') # obtain each data chunk
revDict = dict()
for item in dataFile:
stuff = item.split(':')
revDict[stuff[0]].append(stuff[1])
How something similar can be achieved in R
. Are there any equivalents in R