Split one csv to multiple csv

9 ビュー (過去 30 日間)
novice modeler
novice modeler 2017 年 5 月 4 日
コメント済み: novice modeler 2017 年 5 月 7 日
Friends, I have a csv file with 100 columns. I want to split it into 10 csv files, 10 columns each.Please give me your advice.
  2 件のコメント
per isakson
per isakson 2017 年 5 月 5 日
  • "a csv file with 100 columns" &nbsp How large is it? Does it fit in memory?
  • Does the file have header lines?
novice modeler
novice modeler 2017 年 5 月 7 日
the file size is 2 GB. it has header lines as well.

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

回答 (1 件)

Image Analyst
Image Analyst 2017 年 5 月 5 日
Try this:
data = csvread(filename);
csvwrite('part1.csv', data(:, 1:10));
csvwrite('part2.csv', data(:, 11:20));
csvwrite('part3.csv', data(:, 21:30));
csvwrite('part4.csv', data(:, 31:40));
csvwrite('part5.csv', data(:, 41:50));
csvwrite('part6.csv', data(:, 51:60));
csvwrite('part7.csv', data(:, 61:70));
csvwrite('part8.csv', data(:, 71:80));
csvwrite('part9.csv', data(:, 81:90));
csvwrite('part10.csv', data(:, 91:100));
Adapt as needed.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by