필터 지우기
필터 지우기

Convert from csv to mat format

조회 수: 4 (최근 30일)
elisa ewin
elisa ewin 2017년 1월 24일
댓글: elisa ewin 2017년 1월 24일
I have 28 csv like this
I try to convert these in matlab format so I have used this code:
% return the list of csv files
d=dir('*.csv');
% Use textscan or textread or importdata
for i=1:length(d)
m{i}=textread(d(i).name,'','headerlines',2); % put into cell array
end
but it gives an error
Error using dataread
Trouble reading number from file (row 1, field 1) ==> fwa2500;30332392675;2016-10-14;18:26:57;-45,02
Error in textread (line 175)
[varargout{1:nlhs}]=dataread('file',varargin{:}); %#ok<REMFF1>
I have tried to use also
[ID,PHOTOID,DATA,ORA,LAT,LONG] = textread('1_Adam.csv','%s%d%d%d%d%d');
but it gives the error:
Error using dataread Trouble reading number from file (row 1, field 1) ==> fwa2500;30332392675;2016-10-14;18:26:57;-45,02
Error in textread (line 175)
[varargout{1:nlhs}]=dataread('file',varargin{:}); %#ok<REMFF1>
I have also used 'tableread' but it gives error
Finally I have tried this code
filename = '1_Adam.csv';
delimiterIn = ';';
A = importdata(filename,delimiterIn);
it import data but they are organize in this way
and it's not the format I want: I want that data are divided in 6 column by the delimiter ;
Can you help me?

답변 (1개)

KSSV
KSSV 2017년 1월 24일
doc csvread, use csread instead of textread
  댓글 수: 1
elisa ewin
elisa ewin 2017년 1월 24일
csvread reads comma-separated value (CSV) file and only numerical values; my file has like delimiter semi-colon and has non numerical values

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

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by