Problem reading the csv file with dlmread command.

8 ビュー (過去 30 日間)
Rajat Ahuja
Rajat Ahuja 2017 年 10 月 24 日
編集済み: Stephen23 2017 年 10 月 24 日
Hi, We are trying to read the csv file,containing numerical values having 1095 rows with the header in 1st row.When we try to read the file in Matlab we get the error- R=dlmread('ff3all.csv'); "Error using dlmread (line 147) Mismatch between file and format character vector. Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> date,Mkt-RF,SMB,HML,RF\n"
I've attached the file.Can you please help?
  1 件のコメント
Stephen23
Stephen23 2017 年 10 月 24 日
The file has a header. You need to specify that the range does not include the header.

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

回答 (1 件)

Stephen23
Stephen23 2017 年 10 月 24 日
編集済み: Stephen23 2017 年 10 月 24 日
The file has a header. You need to specify that the range does not include the header:
>> M = dlmread('ff3all.csv',',',1,0)
M =
1.9261e+005 2.9600e+000 -2.3000e+000 -2.8700e+000 2.2000e-001
1.9261e+005 2.6400e+000 -1.4000e+000 4.1900e+000 2.5000e-001
1.9261e+005 3.6000e-001 -1.3200e+000 1.0000e-002 2.3000e-001
1.9261e+005 -3.2400e+000 4.0000e-002 5.1000e-001 3.2000e-001
1.9261e+005 2.5300e+000 -2.0000e-001 -3.5000e-001 3.1000e-001
1.9261e+005 2.6200e+000 -4.0000e-002 -2.0000e-002 2.8000e-001
1.9270e+005 -6.0000e-002 -5.6000e-001 4.8300e+000 2.5000e-001
1.9270e+005 4.1800e+000 -1.0000e-001 3.1700e+000 2.6000e-001
etc

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by