Read file format (.BLK) or convert it on MATLAB?
9 views (last 30 days)
Show older comments
Hey everyone,
I have a file in the format .BLK ( or block file). This is used in a wide variety of applications, including CAD, video and a lot of other stuff. The format that I have simply has a load of text data hidden within it — essentially a time history of collision impacts with a Force Transducer.
if true
"ME'scope Spreadsheet Data Block"
"Measurement Type" "Time Waveform"
"Label" ""
"X Axis Spacing" "Uniform"
"X Axis Units" "sec"
"Measurement Labels" ""
"Y Axis Type" "Real"
"Y Axis DOFS" "2T:2T"
"Y Axis Units" "V"
"Z Axis" ""
"Time" "Real"
0.0000000E+00 -1.7542E-02
+9.7656250E-06 -1.7235E-02
+1.9531250E-05 -1.6303E-02
+2.9296870E-05 -1.6349E-02
+3.9062500E-05 -1.5989E-02
+4.8828120E-05 -1.5112E-02
+5.8593750E-05 -1.5358E-02
+6.8359380E-05 -1.6332E-02
+7.8125000E-05 -1.7491E-02
+8.7890620E-05 -1.7050E-02
+9.7656240E-05 -1.7014E-02
+1.0742190E-04 -1.5180E-02
+1.1718750E-04 -1.4988E-02
+1.2695310E-04 -1.5200E-02
+1.3671880E-04 -1.5894E-02
end
This is a _ very _ short snippet of what the output text file looks like once it has been converted using a secondary application. The issue is that, I have over 300+ .BLK files and to convert them all into .txt would literally take 3+ hours of work.
Can matlab read .BLK files?
1 Comment
dpb
on 9 Dec 2013
Edited: dpb
on 9 Dec 2013
"Automagically", not afaik altho you could search File Exchange for any submissions that might help.
But, "sure" as long as you know the format...I presume you're just describing a stream file with mixed types. Simply use fread and the proper types for the record length and number of records to scan the files. It appears from the ASCII file there are probably 11 header records then a floating point array of possibly variable number of channels along with the time. Reading the header w/ fgetl and parsing the desired fields/records to find out the latter would also be fairly simple, then switch to fread for the data.
The question is then whether the data are actual floating point values or some other storage format.
ADDENDUM: The fgetl suggestion will only work if there are \n characters in the file; otherwise you'll have to know the record lengths. Either is possible; all depends on how the files are created; insufficient data provided to know.
ADDENDUM 2:
It's also possible the vendor of the gear creating the file has a sample code (in C or other language) to read the file--if so, that's a good starting point from which to begin to write equivalent in Matlab.
Answers (0)
See Also
Categories
Find more on Standard File Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!