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??

回答 (1 件)

KSSV
KSSV 2017 年 10 月 25 日

0 投票

use xlsread
[num,txt,raw] = xlsread('test.csv') ;

1 件のコメント

Thomas Hermelin
Thomas Hermelin 2017 年 10 月 25 日
Yes, I forgot to mention it, I'm already using it, but it takes 8 secs to import the data vs 0.1 with textscan. That's why I'm trying to use it. Thanks for your answer !

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

カテゴリ

ヘルプ センター および File Exchange で Large Files and Big Data についてさらに検索

製品

タグ

質問済み:

2017 年 10 月 25 日

編集済み:

2017 年 10 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by