How do I count the number of columns in a csv file?

15 ビュー (過去 30 日間)
Jasmine Shah
Jasmine Shah 2019 年 11 月 23 日
回答済み: Walter Roberson 2019 年 11 月 24 日
I am trying to iterate through the number of columns as well as rows in an excel document. How do i assign a variable called numCols that stores the number of Columns with data in a csv file?

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 11 月 24 日
datatable = readtable('YourFile.csv', 'ReadVariableNames', false); %or true if there is a header
numRows = height(datatable);
numCols = width(datatable);

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by