Importing data from .txt, by last symbol in line.
1 view (last 30 days)
Show older comments
I need to import data from at .txt file, with 10-15 lines set-up like this and some gibberish lines that needs to be ignored.
[Question] [Answer as T or F]
So every line i need to use will end with either a T or an F, and i am trying to figure out the best way to only find the lines that end with T or F.
I need the questions in one array and the answers in another.
I've tried using textscan, but i cant get it to ignore lines that doesnt end on either T or F.
1 Comment
dpb
on 26 Apr 2014
Edited: dpb
on 27 Apr 2014
That would be a regexp kind of parsing but I'm not adept enough to write it otomh w/o more effort than care to spend at the moment.
I'd probably just read the whole file as cell array, then throw away the unwanted lines from memory and process the rest, also in memory.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on String Parsing 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!