Importing a CSV in to a dataset

I have a CSV file (JetQuadrants.csv) that has a row of 8 titles at the top, and corresponding 48 rows of data. 2 columns of data are pure text, the other 6 are purely numeric. I'm attempting to import this csv data in to a dataset, but continue to get this as my dataset
[empty 0-by-344 dataset]
If I delete a column, the 344 decreases.
Here's my code:
sum_data=dataset('File','JetQuadrants.csv','ReadVarNames',true,'ReadObsNames',false,'Delimiter',',');

1 件のコメント

Larissa
Larissa 2011 年 6 月 7 日
Here is the first few lines of my CSV file:
TIME,TOD,EF,SFC,850 JET,700 JET,500 JET,250 JET
1830,D,3,WS,LEX,REX,REN,REX
2300,D,3,DRY,LEX,LEX,LEX,LEX
0435,N,4,WS,REN,JET,JET,LEX
0232,N,4,WS,REX,REX,REX,LEN

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

 採用された回答

Larissa
Larissa 2011 年 6 月 7 日

0 投票

Looks like it was the fault of my CSV file, more specifically the fact that I have a Mac and use stupid Excel for Mac to create my CSV files. When examining my CSV file in Terminal, this is what it reads:
JetQuadrants.csv: ASCII text, with CR line terminators
From what a friend has told me, these line endings are outdated (10+ years) Mac OS line endings.
The solution seems to be to instead choose to save the file as a "Windows Compatible CSV". The resulting file, when examined in Terminal, appears this way:
JetQuadrants2.csv: ASCII text, with CRLF line terminators
Yay Microsoft programmers! rolls eyes

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 6 月 7 日

0 投票

Specify a 'Range' parameter, as you need to skip the extra titles. dataset() is normally only set up to consider the possibility of a single row of column headers.

1 件のコメント

Larissa
Larissa 2011 年 6 月 7 日
I think I wasn't specific enough. I have a single row at the top with 8 columns of header text. Only ONE row of headers here.

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

カテゴリ

ヘルプ センター および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by