我想知道我们应该如何从包含字符串、双精度和字符等的复杂 csv 文件中读取数据。
例如,您能否提供一个成功的命令,可以在此 csv 文件中提取数值?
点击这里。
例如:
yield curve data 2013-10-04
Yields in percentages per annum.
Parameters - AAA-rated bonds
Series key Parameters Description
YC.B.U2.EUR.4F.G_N_A.SV_C_YM.BETA0 2.03555 Euro area (changing composition) - Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous compounding - yield error minimisation - Yield curve parameters, Beta 0 - Euro, provided by ECB
YC.B.U2.EUR.4F.G_N_A.SV_C_YM.BETA1 -2.009068 Euro area (changing composition) - Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous compounding - yield error minimisation - Yield curve parameters, Beta 1 - Euro, provided by ECB
YC.B.U2.EUR.4F.G_N_A.SV_C_YM.BETA2 24.54184 Euro area (changing composition) - Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous compounding - yield error minimisation - Yield curve parameters, Beta 2 - Euro, provided by ECB
YC.B.U2.EUR.4F.G_N_A.SV_C_YM.BETA3 -21.80556 Euro area (changing composition) - Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous compounding - yield error minimisation - Yield curve parameters, Beta 3 - Euro, provided by ECB
YC.B.U2.EUR.4F.G_N_A.SV_C_YM.TAU1 5.351378 Euro area (changing composition) - Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous compounding - yield error minimisation - Yield curve parameters, Tau 1 - Euro, provided by ECB
YC.B.U2.EUR.4F.G_N_A.SV_C_YM.TAU2 4.321162 Euro area (changing composition) - Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous compounding - yield error minimisation - Yield curve parameters, Tau 2 - Euro, provided by ECB
这些是文件中信息的一部分。我试图csvread('yc_latest.csv', 6, 1, [6,1,6,1])
获得值 2.03555,但它给了我以下错误:
Error using dlmread (line 139)
Mismatch between file and format string.
Trouble reading number from file (row 1u, field 3u) ==> "Euro area (changing composition) -
Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous
compounding - yield error minimisation - Yield curve parameters, Beta 0
Error in csvread (line 50)
m=dlmread(filename, ',', r, c, rng);