Read to dataframe then get row whose column equals to value
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Haziq Razali
il 15 Mar 2019
Modificato: Haziq Razali
il 15 Mar 2019
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 Commenti
Risposta accettata
Guillaume
il 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!