Read to dataframe then get row whose column equals to value
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Haziq Razali
el 15 de Mzo. de 2019
Editada: Haziq Razali
el 15 de Mzo. de 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 comentarios
Respuesta aceptada
Guillaume
el 15 de Mzo. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!