textread error handling

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

textread error handling

Fritz Sonnichsen
This happens a lot--I read in a large (200,000 lines) file generated
from a serial port and a few records are "glitched".  textread aborts
producing messages like:

warning: strread: unable to parse text or file with given format string
warning: called from
     strread at line 713 column 7
     textread at line 249 column 31
     drift at line 9 column 40
error: some elements undefined in return list
error: called from
     textread at line 249 column 31
     drift at line 9 column 40

I want textread to handle the error and continue. I can deal with
corrupted data in the returned arrays from there. Of worse case, I would
at least like textread to report which record it stopped on so I can
look into it.

I didn't see an option for this in the doc. Did I miss it?

Thanks
Fritz



Reply | Threaded
Open this post in threaded view
|

Re: textread error handling

Ian McCallion
Just a thought, does textscan leave the opened file positioned at the start of the glitch?

If so at least you can see the erroneous data using a different file function, eg fileread.

Cheers... Ian
On 1 Nov 2018, at 18:51, Fritz Sonnichsen <[hidden email]> wrote:
This happens a lot--I read in a large (200,000 lines) file generated 
from a serial port and a few records are "glitched".  textread aborts
producing messages like:

warning: strread: unable to parse text or file with given format string
warning: called from
    strread at line 713 column 7
    textread at line 249 column 31
    drift at line 9 column 40
error: some elements undefined in return list
error: called from
    textread at line 249 column 31
    drift at line 9 column 40

I want textread to handle the error and continue. I can deal with
corrupted data in the returned arrays from there. Of worse case, I would
at least like textread to report which record it stopped on so I can
look into it.

I didn't see an option for this in the doc. Did I miss it?

Thanks
Fritz





Reply | Threaded
Open this post in threaded view
|

Re: textread error handling

Fritz Sonnichsen
Ian
  at your suggestion,  I converted from textread to textscan and the dataset if loaded just fine. So I am not sure why textread keeps failing-at any rate I am content to use textscan going forward.  Thanks for your suggestion
fritz

On 11/1/2018 2:30 PM, Ian McCallion wrote:
Just a thought, does textscan leave the opened file positioned at the start of the glitch?

If so at least you can see the erroneous data using a different file function, eg fileread.

Cheers... Ian
On 1 Nov 2018, at 18:51, Fritz Sonnichsen <[hidden email]> wrote:
This happens a lot--I read in a large (200,000 lines) file generated 
from a serial port and a few records are "glitched".  textread aborts 
producing messages like:

warning: strread: unable to parse text or file with given format string
warning: called from
     strread at line 713 column 7
     textread at line 249 column 31
     drift at line 9 column 40
error: some elements undefined in return list
error: called from
     textread at line 249 column 31
     drift at line 9 column 40

I want textread to handle the error and continue. I can deal with 
corrupted data in the returned arrays from there. Of worse case, I would 
at least like textread to report which record it stopped on so I can 
look into it.

I didn't see an option for this in the doc. Did I miss it?

Thanks
Fritz






Reply | Threaded
Open this post in threaded view
|

Re: textread error handling

Ian McCallion
:-)
On Fri, 2 Nov 2018 at 18:03, Fritz Sonnichsen <[hidden email]> wrote:

>
> Ian
>   at your suggestion,  I converted from textread to textscan and the dataset if loaded just fine. So I am not sure why textread keeps failing-at any rate I am content to use textscan going forward.  Thanks for your suggestion
> fritz
>
> On 11/1/2018 2:30 PM, Ian McCallion wrote:
>
> Just a thought, does textscan leave the opened file positioned at the start of the glitch?
>
> If so at least you can see the erroneous data using a different file function, eg fileread.
>
> Cheers... Ian
> On 1 Nov 2018, at 18:51, Fritz Sonnichsen <[hidden email]> wrote:
>>
>> This happens a lot--I read in a large (200,000 lines) file generated
>> from a serial port and a few records are "glitched".  textread aborts
>> producing messages like:
>>
>> warning: strread: unable to parse text or file with given format string
>> warning: called from
>>      strread at line 713 column 7
>>      textread at line 249 column 31
>>      drift at line 9 column 40
>> error: some elements undefined in return list
>> error: called from
>>      textread at line 249 column 31
>>      drift at line 9 column 40
>>
>> I want textread to handle the error and continue. I can deal with
>> corrupted data in the returned arrays from there. Of worse case, I would
>> at least like textread to report which record it stopped on so I can
>> look into it.
>>
>> I didn't see an option for this in the doc. Did I miss it?
>>
>> Thanks
>> Fritz
>>
>>
>>
>