Importing data from specific columns of a data structure

1 view (last 30 days)
Hello all,
I am working on a large data file and want to extract the data for specific dates. The format of the file resembles the following:
Date Location Degree1 Degree2
20200101 NY 0 1
20200102 NY 0 0
20200103 NY 1 3
Now what if I want to extract all the data from 20200101 to 20200103?

Accepted Answer

Voss
Voss on 25 Jun 2022
T = readtable('data.txt')
T = 6×4 table
Date Location Degree1 Degree2 ________ ________ _______ _______ 2.02e+07 {'NY'} 0 1 2.02e+07 {'NY'} 0 0 2.02e+07 {'NY'} 1 3 2.02e+07 {'NY'} 1 9 2.02e+07 {'NY'} 2 7 2.02e+07 {'NY'} 2 6
T(T.Date >= 20200101 & T.Date <= 20200103,:)
ans = 3×4 table
Date Location Degree1 Degree2 ________ ________ _______ _______ 2.02e+07 {'NY'} 0 1 2.02e+07 {'NY'} 0 0 2.02e+07 {'NY'} 1 3
  3 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!