Cannot import csv data with textscan
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, I'm trying to import several csv files to use the data. The problem is that xlsread is too slow and csvread, dlmread or importdata don't work. I suspect the encoding to be the source of the problem. So I'm trying to use textscan to do it.
My csv file is looking like that:
N°. x[mm] y[mm] Rotation / x[°]
1 30.92221 3.66636
2 30.92751 3.66634 -0.259299
3 30.93981 3.66649 0.696742
4 30.94510 3.66680 3.36023
5 30.95740 3.66706 1.24399
6 30.96970 3.66663 -2.04397
7 30.97500 3.66638 -2.66614
8 30.98029 3.66614 -2.61545
9 30.99259 3.66589 -1.17048
10 30.99789 3.66629 4.33688
1 31.10346 3.66539 -1.00677
2 30.99259 3.66589 -1.17048
So here i'm using the following code which I think is ok :
file = fopen('test.csv','rt');
data2 = textscan(file,'%f%f%f%f','Delimiter','\t','HeaderLines',1,'TreatAsEmpty',{'N°.','x[mm]','y[mm]','Rotation / x[°]'});
But it's returning
data2 =
[0x1 double] [0x1 double] [0x1 double] [0x1 double]
When I suppress the first line, it works. It appears that the parameter 'headerlines' doesn't work...
Any idea ?
Thank you !!
PS: I work with matlab R2009a
EDIT: The ° symbol appears to be the problem, does anyone know how to suppress it directly from matlab... ? Or any solution to bypass that??
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!