Chossing random data from xls files
1 回表示 (過去 30 日間)
古いコメントを表示
I have hundreds of excels files in different folders with data on hundreds of records,I want to record the data to a single (excel) file that choose randomly files from the folder and the rows (randomly too...) Please guide me what is the procedure that I adopt to cater this thing. Thanks
3 件のコメント
Salaheddin Hosseinzadeh
2014 年 8 月 12 日
It's a pure programming problem.
Anyone with a little creativity, knowledge of programming, and of course some hours to think and trial and error should be able to tackle this really!
I don't see a point to ask this!
採用された回答
Geoff Hayes
2014 年 8 月 12 日
Muahmmad - do you know what the minimum number of rows are in each file? If so, then you could create a vector of integers, one for each file, where the sum of all elements in the vector is 100000 (the number of rows that you want to extract). You can initialize the vector to that of all ones
numFiles = 29000;
selRowsPerFile = ones(numFiles,1);
so that at least one row is selected from each file.
There may be some code on the MATLAB File Exchange that can create this vector for you (subject to the constraint of each element in the vector being at least one, and the sum of the elements in the vector being exactly 100000). If not, then you could write a simple while loop with randi to randomly select more rows for each file, until the 100000 rows have been assigned.
Then, once you have your list of files, for each file you can use xlsread to read in the data and then randomly selected a number of rows (again using randi) from that data (using the selRowsPerFile vector to tell you how many rows to read). Once those rows have been selected, then use xlswrite to write the data to file.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!