フィルターのクリア

Convert CSV to excel file, or read

4 ビュー (過去 30 日間)
Vicipn
Vicipn 2011 年 3 月 31 日
コメント済み: Walter Roberson 2017 年 3 月 17 日
Hi there
Can anybody tell me how convert csv files to excel files with MAtlab. I´ve benn trying read them to ussing csvread, also dlmread, but appear an error: Mismatch between file and format string. If can anybody help me I appreciate

回答 (3 件)

Walter Roberson
Walter Roberson 2011 年 3 月 31 日
Does it give you a partial result? If so then look in the file at the lines right near where it ends and see if you can see anything unusual.
If you show the format of a sample line, then someone could probably help you figure out a format string to use with textread()
  1 件のコメント
Vicipn
Vicipn 2011 年 4 月 2 日
No, and I´ve been tried to read specific columns with values only but it isn´t work

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


mohammed
mohammed 2011 年 4 月 1 日
may you can use excel to do this task instead of matlab
  1 件のコメント
Vicipn
Vicipn 2011 年 4 月 2 日
yes but the problem is that my professor give me that work, accordind to him, it´ll be possible

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


Harish TV
Harish TV 2017 年 3 月 17 日
編集済み: Walter Roberson 2017 年 3 月 17 日
Easy method
clear;
clear all;
fileip='filename.csv';
g=char(fileip);
g=g(1:end-4)
fileop=horzcat(g,'.xlsx')
g=fileip(1:end-4);
[~,~,F]=xlsread(fileip);
F=cellstr(F);
%delete the header rows (4 rows)
F([1:4],:)=[];
for a=1:size(F,1);
b=F(a,1);
c=char(b);
D(a,:)=strsplit(c,',');
end
xlswrite(fileop,D);
disp(['--------------Process complete---------------------']);
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 3 月 17 日
Oddly, csv files are not always readable by xlsread. I ran into one just a couple of days ago.
In the time frame that the question was asked, the problem was likely a csv file that contained text. csvread() back then could not handle text at all, not even in header lines; in more modern versions, csvread() can be instructed to skip a fixed number of lines (even if they have text), and can be instructed to skip a fixed number of fields per line (even if they have text); however, csvread() still (in current versions) cannot deal with trailing fields that contain text, even if you do not want to read them.
Unfortunately when the original poster failed to give a few sample lines of the file, we dropped the question.

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by