splitting a .txt or .xlsx into separate data sets
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Matthew Thomas
2019년 11월 19일
편집: Matthew Thomas
2020년 1월 24일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!