How to export to csv in multiple rows instead of all columns?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello all, I am developing a code to export a long (>32,000 values) comma separated value char variable set of ASCii scope measurements into a comma separated value, which is saved in Excel. Excel limits its # of columns to 16,384, but rows are limited to 1,048,576. For this reason I want to either split the data into multiple rows, or save all data into column A as rows. This is my export code:
function csvExportData(channel,csvData)
if (channel == 1)
splitData = strsplit(csvData,','); %remove commas
exportData = mat2dataset(splitData); %creates dataset array
export(exportData,'file','scopeDataTestCh1.csv','Delimiter',',','WriteVarNames',false); %write to scopeDataTest.csv
end
end
csvData is in the form: 2.79E-02,1.63E-02,5.8E-03,-2.6E-03,-1.11E-02............... where the values vary, and the length varies, sometimes being very long. I can not have a limit to the length of the data, as its important that I can get all the y-values for the scope's measurement (up to 80 GSa/s).
Thanks in advance for any tips y'all can provide.
3 Commenti
Risposte (2)
Image Analyst
il 17 Ago 2016
Did you try this to export into an Excel workbook:
% Create sample data
csvData = sprintf('%.2f', rand());
for k = 1 : 7000
csvData = sprintf('%s,%.2f', csvData, rand());
end
% Now, csvData is a 35,004 character long character array
% of numbers separated by commas.
% Now we have sample data and we can begin.
% Now remove commas and transpose.
splitData = strsplit(csvData,',')';
% splitData is a 70001 cell array in a column.
% Write it to Excel into column A
xlswrite('delete me.xlsx', splitData, 'Results', 'A1');
% Now all 7001 numbers will be in rows 1-7001 of the workbook column A.
0 Commenti
Image Analyst
il 19 Ago 2016
J, you say "I would prefer to save in MATLAB, as I will be doing my post-processing in MATLAB" so then just use save(), like
% Now remove commas and transpose.
splitData = strsplit(csvData,',')';
% Save to a .mat file in proprietary MATLAB format.
save(someFileName, 'splitData');
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!