Read to dataframe then get row whose column equals to value
2 views (last 30 days)
Show older comments
The task above would be extremely easy using Pandas. How can I do it in matlab given the text.txt below?
df = pd.read_csv("text.txt")
data = df[df["#video_id"] == "video_0001"]
#video_id, pedestrian_id, group size, motion direction, designated, signalized, gender, age, num lanes, traffic direction, intersection, crossing
video_0001, pedestrian1, 1, LONG, ND, n/a, female, senior, 2, TW, no, -1
video_0001, pedestrian2, 1, LONG, ND, n/a, female, adult, 2, TW, no, -1
video_0002, pedestrian1, 2, LAT, D, NS, male, adult, 2, TW, no, 1
video_0002, pedestrian2, 2, LAT, D, NS, female, adult, 2, TW, no, 1
video_0003, pedestrian, 1, LAT, ND, S, female, adult, 1, OW, yes, 1
video_0004, pedestrian, 1, LONG, ND, n/a, female, adult, 2, TW, yes, 0
0 Comments
Accepted Answer
Guillaume
on 15 Mar 2019
It probably is just as easy in matlab:
df = readtable('text.txt', 'TextType', 'string');
data = df(df.video_id == "video_0001", :)
assuming your headerline doesn't start with #
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical 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!