Importing csv with strings and texts without losing columns

6 ビュー (過去 30 日間)
erik frogner
erik frogner 2019 年 8 月 20 日
回答済み: Jyotsna Talluri 2019 年 8 月 27 日
I want to write a script that can import a csv file at each iteration of a loop, so that I can withdraw data for each file. The number of rows and columns are varying between each file and they all have both text and numbers at varying locations.
I've tried using readtable like so:
readtable('23-Jul2019_001.csv', 'Delimiter', ',', 'ReadVariableNames', false);
But the result is a variable that is 32333x2, when it is supposed to be 1884x252. When i manually import by clicking on "import data" I get the right amount of columns and rows, and I can generate a script from this. But the script seems to be specific to that file, so it doesn't seem to be flexible enough to import several different data sets.
I also need the first two columns to be categorical or text. And the delimiter is commas.
Any advice?
  2 件のコメント
Stephen23
Stephen23 2019 年 8 月 20 日
"Any advice?"
Upload two (or more) sample files for us to work with, by clicking the paperclip button.
erik frogner
erik frogner 2019 年 8 月 21 日

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

回答 (1 件)

Jyotsna Talluri
Jyotsna Talluri 2019 年 8 月 27 日
Here all the entire data of a excel file is read into a single column.It might be due to large set of data.A possible alternative could be to use 'xlsread' function .
[n,nn,s]=xlsread('23-Jul2019_002.csv');
Here we can obtain text data and numeric data seperately

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by