Re: [R] reading formatted txt file into a data frame

2010-05-07 Thread Tony B
Thank you all for your help, this has solved my problem. My main problem with using gsubfn was that i was getting confused by the square brackets in [^]]+[^] but I now have a much better understanding of what this means. Cheers! Tony Breyal On 6 May, 19:38, Gabor Grothendieck wrote: > This is

Re: [R] reading formatted txt file into a data frame

2010-05-06 Thread Gabor Grothendieck
This is very similar to the solution in Jim's post except the regular expressions can be made slightly simpler due to the use of strapply and a few of the regular expressions have been made a bit different even apart from that. Its not always clear what the general case is based on example so the

Re: [R] reading formatted txt file into a data frame

2010-05-06 Thread jim holtman
Try this: > cat(c("[ID: 001 ] [Writer: Steven Moffat ] [Rating: 8.9 ] Doctor Who", + "[ID: 002 ] [Writer: Joss Whedon ] [Rating: 8.8 ] Buffy", + "[ID: 003 ] [Writer: J. Michael Straczynski ] [Rating: 7.4 ]Babylon"), + sep = "\n", file = "tmp.txt") > > # read in the data and parse

Re: [R] reading formatted txt file into a data frame

2010-05-06 Thread Steve Lianoglou
Hi Tony, On Thu, May 6, 2010 at 9:58 AM, Tony B wrote: > Dear all > > Lets say I have a plain text file as follows: > >> cat(c("[ID: 001 ] [Writer: Steven Moffat ] [Rating: 8.9 ] Doctor Who", > +       "[ID: 002 ] [Writer: Joss Whedon ] [Rating: 8.8 ] Buffy", > +       "[ID: 003 ] [Writer: J. Mic

[R] reading formatted txt file into a data frame

2010-05-06 Thread Tony B
Dear all Lets say I have a plain text file as follows: > cat(c("[ID: 001 ] [Writer: Steven Moffat ] [Rating: 8.9 ] Doctor Who", + "[ID: 002 ] [Writer: Joss Whedon ] [Rating: 8.8 ] Buffy", + "[ID: 003 ] [Writer: J. Michael Straczynski ] [Rating: 7.4 ] Babylon [5]"), + sep = "\n",