How can I load a csv file into matlab?

1 回表示 (過去 30 日間)
Emma Vos
Emma Vos 2017 年 3 月 10 日
編集済み: Guillaume 2017 年 3 月 10 日
I would like to import data from my computer using the following function :
fileID=fopen('C:\Users\Emma Vos\Documents\MIWB\OT4\GE\1_16 jaar data.csv','r');
I do not succeed. The program gives me the error : Error: The input character is not valid in MATLAB statements or expressions.
What is it due to ? how can I help it ?

回答 (2 件)

Guillaume
Guillaume 2017 年 3 月 10 日
編集済み: Guillaume 2017 年 3 月 10 日
Matlab error message is certainly not helpful.
The issue you have is that there is an invisible unicode control character (U+202A, which is meant to force text to be interpreted as left-to-right) before your first '. I can't tell you how it got there, it's been created by whatever you've copied the string from.
The fix: type the first part of the command and only copy/paste the path itself without the enclosing quotes. You should obtain the following which, although looking the same, does not contain the offending invisible character:
fileID =fopen('C:\Users\Emma Vos\Documents\MIWB\OT4\GE\1_16 jaar data.csv','r'); %This string has no invisible control characters
  1 件のコメント
Emma Vos
Emma Vos 2017 年 3 月 10 日
it worked tks

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


ES
ES 2017 年 3 月 10 日
csvread is more useful. Please try.
  1 件のコメント
Guillaume
Guillaume 2017 年 3 月 10 日
While csvread would indeed make parsing the file a lot easier, the issue reported here has nothing to do with the way the file is read.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by