Find specific strings in text files
Show older comments
I have a text file which looks like this (stored as 'images.txt'):
{{{"n00442981", 35337, "JPEG", "n00442981_35337.JPEG"}, {0.09406380813043877, 0.17861690849412887, 0.04507771067833858, 0.029303014634447882, 0.012220201853215573, 0.1257934815481311, 0.13825580156603434, 0.9389469278576577, 0.004618802153517006, 0.04270831300812525, 0.19442907875795395}}, {{"n00442981", 29039, "JPEG", "n00442981_29039.JPEG"}, {0.3070995936627196, 0.25283420197797524, 0.2906750395366373, 0.021067754208260528, 0., 0.10090499582190261, 0.19841618874784198, 0.8236737841365335, 0.05066403971048989, 0.0903942641689859, 0.13454220259113817}}, {{"n00442981", 23083, "JPEG", "n00442981_23083.JPEG"}, {0.11339606107209661, 0.2696565717105123, 0.036000000000000004, 0.002309401076758503, 0., 0.023094010767585032, 0.006110100926607786, 0.9520056022244127, 0.008640987597877146, 0.027519689920733725, 0.07353910524340095}}}
I want to extract the names of the JPEGs into a cell array, and the 11 values that represent each JPEG into a matrix (where each row is a JPEG and the columns are the 11 values).
Such that I get:
A = {'n00442981_35337', 'n00442981_29039', 'n00442981_23083'};
and
B = [0.09406380813043877, 0.17861690849412887, 0.04507771067833858, 0.029303014634447882, 0.012220201853215573, 0.1257934815481311, 0.13825580156603434, 0.9389469278576577, 0.004618802153517006, 0.04270831300812525, 0.19442907875795395; 0.3070995936627196, 0.25283420197797524, 0.2906750395366373, 0.021067754208260528, 0., 0.10090499582190261, 0.19841618874784198, 0.8236737841365335, 0.05066403971048989, 0.0903942641689859, 0.13454220259113817; 0.11339606107209661, 0.2696565717105123, 0.036000000000000004, 0.002309401076758503, 0., 0.023094010767585032, 0.006110100926607786, 0.9520056022244127, 0.008640987597877146, 0.027519689920733725, 0.07353910524340095]
Could someone please help me do this?
Thank you in advance, I appreciate any help at all!!
Accepted Answer
More Answers (0)
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!