Read to dataframe then get row whose column equals to value

2 vues (au cours des 30 derniers jours)
Haziq Razali
Haziq Razali le 15 Mar 2019
Modifié(e) : Haziq Razali le 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
csvread and dlmread only accepts files containing numeric values

Réponse acceptée

Guillaume
Guillaume le 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 #

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by