Prev: PI
Next: Carriage return in mex files
From: Tracy on 9 Jun 2010 13:00 I have a blob of ascii data that i am reading from a tcpip object. The data 6 columns of fixed with ascii and up to 64K rows. i read it in as a <1x5504> char (for just 16 rows). I want to create a 6xM array of cells each containing the fields of the data. I have tried using textscan on the data but it only reads the 1st field. i.e. d=textscan(data, '%s %s %s %s %s %s'); any one have any tips??
From: Walter Roberson on 9 Jun 2010 13:08 Tracy wrote: > I have a blob of ascii data that i am reading from a tcpip object. The > data 6 columns of fixed with ascii and up to 64K rows. i read it in as > a <1x5504> char (for just 16 rows). I want to create a 6xM array of > cells each containing the fields of the data. I have tried using > textscan on the data but it only reads the 1st field. > > i.e. > > d=textscan(data, '%s %s %s %s %s %s'); > > any one have any tips?? Could you give an example of a couple of lines, and if the fields might happen to look like numbers please indicate whether you want to store them as strings or as numbers.
From: Tracy on 9 Jun 2010 13:31 sure - and thanks for the quick response The data looks like this - i want all of the columns to be strings. this is just 1 row. there can be up to 64K rows. DataPat CRIT 01/01/70:00:00:28 thunder.cpp 0516 Thunder 0 Alignment failed 0x0
From: Tracy on 9 Jun 2010 13:36 "Tracy " <tracy(a)stratalight.com> wrote in message <huoj4q$dv5$1(a)fred.mathworks.com>... > sure - and thanks for the quick response > > The data looks like this - i want all of the columns to be strings. this is just 1 row. there can be up to 64K rows. > > DataPat CRIT 01/01/70:00:00:28 thunder.cpp 0516 Thunder 0 Alignment failed 0x0 I should have mentioned that this is 6 columns which are fixed length - 8 chars 8 chars 32 chars 32 chars 6 chars 256 chars it's not apparent from the display that this is the case - they are null terminated.
From: Walter Roberson on 9 Jun 2010 14:19
Tracy wrote: > "Tracy " <tracy(a)stratalight.com> wrote in message > <huoj4q$dv5$1(a)fred.mathworks.com>... >> sure - and thanks for the quick response >> >> The data looks like this - i want all of the columns to be strings. >> this is just 1 row. there can be up to 64K rows. >> >> DataPat CRIT 01/01/70:00:00:28 >> thunder.cpp 0516 Thunder 0 Alignment failed 0x0 > > I should have mentioned that this is 6 columns which are fixed length - > 8 chars > 8 chars > 32 chars > 32 chars > 6 chars > 256 chars > > it's not apparent from the display that this is the case - they are null > terminated. Null termination is usually a signal to end the string; I'm not surprised only a single field was returned. Try something like this, textscan('%8c\0%8c\0%32c\0%32c\0%6c\0%256c', ... 'Whitespace', '', 'Delimeter', ''); |