How do I load a file with a csv extension with numbers and text in matlab?

2 ビュー (過去 30 日間)
Anonymous
Anonymous 2018 年 8 月 22 日
編集済み: dpb 2018 年 8 月 23 日
Say the file is called name.csv
I've tried loading it by doing csvread('name.csv') but that doesn't seem to work. The mathworks page for loading csv files just show examples with .dat file extensions.
  4 件のコメント
Anonymous
Anonymous 2018 年 8 月 22 日
Yeah my file must have some text. How do I load a csv that has numbers and text then?
Walter Roberson
Walter Roberson 2018 年 8 月 22 日
These days, readtable() is often the most convenient option for reading csv files.
Otherwise, if the text is only on the top lines, you can use csvread() with a R value equal to the number of rows to skip (*not* the row number to start reading at -- so R of 1 means to skip 1 row and start reading from row 2)
For mixes of text and numbers, you can use textscan() with an appropriate format string.

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

回答 (1 件)

ahmed nebli
ahmed nebli 2018 年 8 月 23 日
編集済み: dpb 2018 年 8 月 23 日
you can use the csvimport, like this:
%read data example: Import columns as column vectors
[X Y Z] = csvimport('vectors.csv', 'columns', {'X, 'Y', 'Z'});
%remove headers
X(1) = [];
Y(1) = [];
Z(1) = [];
(sure wish folks would format their code to be legible...dpb]

カテゴリ

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