Re: Unformatted File IO

*To*: mathgroup at smc.vnet.net*Subject*: [mg44470] Re: Unformatted File IO*From*: Bill Rowe <readnewscix at mail.earthlink.net>*Date*: Wed, 12 Nov 2003 08:01:22 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

On 11/10/03 at 4:52 AM, bcolletti at compuserve.com (Bruce W. Colletti) wrote: > The code splits "hello there" which must stay intact as a list element. Any > ideas? Thanks. Here is code that will work for your specific example but may not be adequate in general parseString[x_String] := Module[{p = StringPosition[x, "\""], len = StringLength@x, data}, If[Length@p == 0, data = ReadList[StringToStream[x], Number], p = First /@ p; data = StringTake[x, # + {1, -1}] & /@ Partition[p, 2]; If[len > Last@p, data = Flatten@{data, ReadList[ StringToStream@StringDrop[x, {1, Last@p}], Number]}]]; Return@data] parseString/@ReadList[filename,String] where filename contains your example data. Note, this routine assumes any line that contains both numeric and doble quoted string data the numeric data follows the double quoted string data as was the case in your example. If I were to add a line such as "hello there" 3 "abs" or 3 "hello there" the numeric data will be skipped by this routine. This can be changed with additional complexity in the routine. -- To reply via email subtract one hundred and nine