splitting a .txt or .xlsx into separate data sets
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Andrew Dickins
le 19 Nov 2019
Modifié(e) : Matthew Thomas
le 24 Jan 2020
I have a set of data output from Polyworks that's essentiall miltiple line profiles and I'm looking for a way to automated separating them to save time as I run through multiple sets of data
the data sets are put out in this format as a .txt
# dataset 1 - 0
x1,y1,z1
x2,y2,z2
x3,y2,z2
# dataset 1 - 1
x4,y4,z4
x5,y5,z5
# dataset 1 - 2
x6,y6,z6
# dataset 2 - 0
x1,y1,z1
x2,y2,z2
in this case there's 2 data sets, however the data sets are split into subsets, eq 1 - 0, 1 - 1, 1 - 2
x y and z are positional values
each set starts with a '- 0' and the other nnumbers I just want the rows deleting so the file would look more like this:
# dataset 1 - 0
x1,y1,z1
x2,y2,z2
x3,y2,z2
x4,y4,z4
x5,y5,z5
x6,y6,z6
# dataset 2 - 0
x1,y1,z1
x2,y2,z2
following that I'd like the different datasets to be split into separate files so I can process them all individually and compare them
the amount of "sub" sets for each dataset is incosistent but they always start at - 0 and for addition reference the dataset names are actually more like "# AMSA4 combined - Cloud - clean.txt -meas- (13) - 0" for example
I'm sure there's a simple solution to this but I've not been able to find anything helpful from searching
0 commentaires
Réponse acceptée
Matthew Thomas
le 19 Nov 2019
Modifié(e) : Matthew Thomas
le 24 Jan 2020
I've attatched a function I've written that should help you with this. It will go through the text file and produce new text files named 1.txt, 2.txt, 3.txt .. etc for each "dataset", where the subset markers have been removed. It might need some minor editing to work for your specific case, but hopefully this will get you most of the way there.
It doesn't actually "load" the datasets as numbers at any point, as it sounds like you know how to do that already once they have been seperated out and cleaned up. If you aren't quite sure, look into the function textscan.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!