Matlab function to read data files having .Cmn extension

8 ビュー (過去 30 日間)
Dr. Bapan Paul
Dr. Bapan Paul 2020 年 9 月 23 日
編集済み: Dr. Bapan Paul 2020 年 9 月 25 日
I want to open and read data files in Matlab having extension '.Cmn'. Please inform me weather there is any Matlab function to open and read this type of data files. I could not attach a sample data file here as the file format is not supported.
I don't know much about CMN files. Some information is provided in the website 'FilExt' as "the CMN file type is primarily associated with Systems Management Server (SMS) by Microsoft Corporation.You need a suitable software like Systems Management Server (SMS) from Microsoft Corporation to open a CMN file."
The website recognizes the file as a 'text file' but I couldnot read the file in Matlab using the 'textscan' function. Also the 'online viewer' in the website reads the data file as:
chum, Kazakhstan
42.99850 74.75110 716.33210
MJdatet Time PRN Az Ele Lat Lon Stec Vtec S4
57372.372569 8.941667 1 319.78 11.39 50.417 64.330 37.91 12.65 -99.000
57372.372917 8.950000 1 319.74 11.58 50.350 64.431 37.85 12.68 -99.000
57372.373264 8.958333 1 319.70 11.77 50.284 64.529 37.69 12.68 -99.000
57372.373611 8.966667 1 319.66 11.96 50.218 64.626 37.53 12.68 -99.000
57372.373958 8.975000 1 319.62 12.15 50.153 64.722 37.42 12.70 -99.000
57372.374306 8.983333 1 319.58 12.34 50.088 64.816 37.20 12.68 -99.000
57372.374653 8.991667 1 319.54 12.52 50.025 64.908 37.00 12.67 -99.000
57372.375000 9.000000 1 319.50 12.71 49.961 64.999 36.84 12.67 -99.000
57372.375347 9.008333 1 319.45 12.90 49.899 65.088 36.57 12.63 -99.000
  5 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 23 日
readtable() has no problem reading the xlsx file, automatically skipping the first two lines.
Do you need the first two lines?
Dr. Bapan Paul
Dr. Bapan Paul 2020 年 9 月 24 日
Thanks for the suggestion. I have now attached a zipped sample CMN data file.
I wish to read directly the CMN data file. And I don't need the first two lines.

サインインしてコメントする。

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 9 月 23 日
編集済み: Ameer Hamza 2020 年 9 月 23 日
Try the following code. It ignores the first two lines of the file and starts from the line
MJdatet ...
The first row is used as column names for the table, and the rest is used as numeric data.
f = fopen('data.txt');
data = textscan(f, '%s%s%s%s%s%s%s%s%s%s', 'HeaderLines', 2);
data = [data{:}];
fclose(f);
column_names = data(1, :);
numeric_data = data(2:end,:);
numeric_data = cellfun(@(x) str2double(x), numeric_data);
T = array2table(numeric_data, 'VariableNames', column_names);
  3 件のコメント
Dr. Bapan Paul
Dr. Bapan Paul 2020 年 9 月 24 日
編集済み: Dr. Bapan Paul 2020 年 9 月 24 日
Good suggestion. Thanks.
Initially I was searching for a specific matlab function which can read CMN data files. But after this discussion, the problem is solved. CMN files can be read using the textscan function.
Thank you all.
Ameer Hamza
Ameer Hamza 2020 年 9 月 24 日
Yes, that would heve been a better solution.
Following will also work
readmatrix('data.txt', 'NumHeaderLines', 3)

サインインしてコメントする。

その他の回答 (1 件)

Dr. Bapan Paul
Dr. Bapan Paul 2020 年 9 月 24 日
編集済み: Dr. Bapan Paul 2020 年 9 月 25 日
I can now directly read CMN data files using the below code:
% Read CMN data files
f = fopen('chum350-2015-12-16.Cmn');
file_data=textscan(f, '%f %f %f %f %f %f %f %f %f %f','headerlines',3,'delimiter',' '); % reading the text file and extracting the data in a cell
Raw_data=cell2mat(file_data); % converting cell data into a mat file

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by