Mismatch between file and format string.

Hi there,
I am trying to read the fifth column of attached .CSV file(from row 1377 to 1192) with this simple code:
data = csvread('semga.csv');
CLOSE = data(1377:1192,5);
But I get this error:
Error using dlmread (line 147)
Mismatch between file and format string.
Trouble reading 'Numeric' field from file (row number 1, field number 1) ==>
DATE,OPEN,HIGH,LOW,CLOSE,PRICE,YCLOSE,VOL,TICKS\n
Error in csvread (line 48)
m=dlmread(filename, ',', r, c);
Error in sorting (line 8)
data = csvread('semga.csv');
What is the problem and how can I fix it?

 채택된 답변

Stephan
Stephan 2019년 1월 21일
편집: Stephan 2019년 1월 21일

2 개 추천

Hi,
use readtable, then extract the data from the variable CLOSE (=column named CLOSE) in ascending order:
data = readtable('semga.csv');
CLOSE = data.CLOSE(1191:1376);
Note that your table has only 1376 entries, since the first row are variable names. So i changed
(1192:1377)
to
(1191:1376)
If needed use flip function, to get the order you want:
CLOSE = flip(CLOSE)
Best regards
Stephan

댓글 수: 3

Thank you Stephan!
But in grabbed data it seems there is a problem from row 1 to 67(I like to have simple numbers like after row 67. How can I delete the numbers after the point(.))?:
1745.08000000000
1720.42000000000
1700.34000000000
1700.34000000000
1719.51000000000
1678.42000000000
1672.03000000000
1653.76000000000
1605.36000000000
1640.07000000000
1636.41000000000
1674.77000000000
1652.85000000000
1637.33000000000
1666.55000000000
1649.20000000000
1651.02000000000
1637.33000000000
1638.24000000000
1640.07000000000
1604.45000000000
1607.19000000000
1635.50000000000
1638.24000000000
1657.42000000000
1626.37000000000
1667.46000000000
1700.34000000000
1639.15000000000
1627.28000000000
1715.03000000000
1716.02000000000
1693.09000000000
1699.07000000000
1773.86000000000
1759.90000000000
1719.01000000000
1708.05000000000
1716.02000000000
1716.02000000000
1694.09000000000
1677.14000000000
1701.07000000000
1712.04000000000
1784.82000000000
1878.55000000000
1914.45000000000
1985.24000000000
2027.12000000000
2056.04000000000
2125.84000000000
2042.08000000000
2014.16000000000
1999.20000000000
2010.17000000000
2012.16000000000
2012.16000000000
2007.18000000000
2001.20000000000
2010.17000000000
1977.27000000000
1919.43000000000
1958.32000000000
1983.25000000000
1952.34000000000
2014.16000000000
2022.14000000000
2069
1911
1851
1855
1814
1831
1959
1915
1827
1844
1883
1906
2030
2238
2290
2376
2317
2323
2255
2289
2480
2607
2622
2637
2617
2530
2466
2605
2707
2764
2970
3321
3240
3434
3596
3929
4275
4702
5147
5282
5357
5419
6012
5527
5117
5090
4825
4241
4532
4302
3988
3644
3973
4356
4479
4923
5092
4776
4379
4027
4060
4392
4789
5020
4699
4646
4975
5277
5215
4989
5224
5189
5006
4891
4504
4555
4321
4415
4394
4088
4181
4080
3844
4125
4425
4410
4598
4933
4915
4726
4830
4906
5130
5118
4867
4872
4993
5052
4917
4806
4934
4950
4897
4857
4801
4765
4623
4839
4870
4786
4990
4986
4963
4975
4921
5008
5393
5532
5201
Stephan
Stephan 2019년 1월 21일
편집: Stephan 2019년 1월 21일
you could use the round function:
CLOSE = round(CLOSE)
reza
reza 2019년 1월 21일
Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2019년 1월 21일

댓글:

2019년 1월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by