How to read large data file with different data types

1 回表示 (過去 30 日間)
Vida
Vida 2012 年 10 月 30 日
I am having difficulty reading a large file 1GB. which looks like this
"-----------------------------------------------
per 8/23/2012 10:07:48 AM 93 122.00000
per 8/23/2012 10:07:48 AM 96 123.00000
Start 8/23/2012 10:07:49 AM 99 1
Order 8/23/2012 10:08:09 AM 99 Start session OK (Please bla and time, the difference between device time, please adjust time): 8/23/2012 10:08:09 AM
per 8/23/2012 10:08:09 AM 99 122.00000
per 8/23/2012 10:08:09 AM 102 122.00000
----------------------------------------------------"
The whole file is generally consistent with this foramt "per 8/23/2012 10:08:09 AM 102 122.00000". But sometimes there are lines that have sentences. I want to capture the whole data and ignore or store those sentences in the 6th column or somewhere else.
I am trying this
format = '%s %s %s %s %s %s' [segarray idx]= textscan(file_id, format, block_size, 'delimiter', '\n');
This stores the whole row
'Start 8/23/2012 10:07:48 AM 0 1'
'per 8/23/2012 10:07:48 AM 15 122.00000'
'per 8/23/2012 10:07:48 AM 33 121.00000'
where I want to have them separate Cell array columns (1 to 6 colums).In this way I can get rid of the long sentence.
when I try this without delimiter [ segarray idx]= textscan(file_id, format, block_size); I get the long sentence in different indeces of cell array. I want to conserve the indexing of data. 1-'per'
2-'per'
3-'Order'
*4-'session'
6-'and'
7-'IPG''s'
8-'over'
9-'time):'*
10-'per'
11-'per' Where the second column doesnt match
1-'8/23/2012'
2-'8/23/2012'
3-'8/23/2012'
4-*'OK'
5-'device'
6-'time'
7-'15'*
8-'8/23/2012'
9-'8/23/2012'
that sentence has shifted the corresponding information one index down. This has a ripple effect on the subsequent corresponding columns.
Can someone please suggest a way out of this?

回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by