Effacer les filtres
Effacer les filtres

transposing and converting excel file

4 vues (au cours des 30 derniers jours)
Muhsin
Muhsin le 10 Déc 2017
Commenté : Muhsin le 11 Déc 2017
Hello; I am a new user. I would like to automate a process that will save me a lot of time. In attached excel file I have some calculations of stresses for different parts. I want to take the data of "Part ID" and "Mean Stresses" and of a string format, which is on right side of excel file, that is compatible with the software I use. The red color and blue color represent the location of the data in string. The rest of the data should not be changed (Each sheet has different data). Finally, all the output should be dumped into a txt file. Is that a possible work to do so? Any kind of help is appreciated. Thank you. Muhsin

Réponses (1)

Walter Roberson
Walter Roberson le 10 Déc 2017
fid = fopen('final output.txt', 'rt');
data = cell2mat( textscan(fid,'%f%f%f%f%f%f%f%f', 'delimiter',',','comment','*') );
fclose(fid);
data3d = permute(reshape(data,7,[],8),[1 3 2]);
Now data3d is a numeric array, 7 by 8 by the number of "*MAT_USER_DEFINED_MATERIAL_MODELS" blocks. Because your input lines are not all the same size, the shorter rows are padded with NaN.
Nothing in the input file you attached is an obvious part id or mean stress, or red or blue. Also, I do not see what you are asking to do with the data. But at least the above code will read the data into a consistent format suitable for mechanical processing.
  3 commentaires
Walter Roberson
Walter Roberson le 11 Déc 2017
That csv appears to have two Part ID and two mean stress entries on each of the main lines.
I do not understand how the input is to map into the output file.
Muhsin
Muhsin le 11 Déc 2017
Dear Walter, I would like to copy the string data on right side of the table for each Part ID that has different Mean Stress values in en each excel sheet. For each Part ID only colored texts is going to be modified. For example, for "layer 16" I am gonna have 32 (from 116 to 3216) data set of string with similar format of input "final output".The only change among these data sets are Part IDs and Mean Stress values which are colored in .csv file as example. Hope I was able to explain it. Thank you.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by