can't do a simple csvread for some reason

I'm just trying to do a csvread and I can't seem to get it working. I opened a text edit file (mac) and put:
1,2,3, 4,5,6, 7,8,9
Then saved it as 'csvtest'. Then I renamed the file in the browser window, changing the .rtf to .csv.
I then put that file in my MATLAB folder and in matlab I typed: -
M = csvread('csvtest.csv');
I got this error: -
Error in ==> Ass_2_data_A at 1
M = csvread('csvtest.csv');
Not sure what's going wrong

댓글 수: 3

Walter Roberson
Walter Roberson 2012년 12월 12일
It just said "Error" and didn't say what the error was??
Tom
Tom 2012년 12월 12일
Sorry, I must have missed the full error. It said this:
??? Error using ==> dlmread at 145 Mismatch between file and format string. Trouble reading number from file (row 1, field 1) ==> {\rtf
Error in ==> csvread at 50 m=dlmread(filename, ',', r, c);
Error in ==> untitled at 1 M = csvread('csvtest.csv');
Mark Hayworth
Mark Hayworth 2012년 12월 12일
You probably have something else in there, like a blank line, a header line, or something that's not a line with 9 numbers on it.

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

 채택된 답변

Walter Roberson
Walter Roberson 2012년 12월 12일

0 개 추천

A file that starts with {\rtf is not a csv file, it is a RTF file, which is a method of encoding text with formatting. You will need to use your editor to save the file as text instead of as RTF.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품

태그

질문:

Tom
2012년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by