Read to dataframe then get row whose column equals to value
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Guillaume
2019년 3월 15일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!