How do I extract the contents of an HTML table on a web page into a MATLAB table?
Mostra commenti meno recenti
I'd like to plot and analyze the TSA traveler data from this website: https://www.tsa.gov/coronavirus/passenger-throughput
The data is embedded on the page as an HTML table element.
How do I extract the table content into a MATLAB table?
Risposta accettata
Più risposte (1)
Starting in R2021b, you can directly use readtable for HTML tables:
readtable("https://www.tsa.gov/coronavirus/passenger-throughput",...
FileType="html",ReadVariableNames=true,ThousandsSeparator=",")
3 Commenti
Bucks Lin
il 14 Apr 2023
thanks, the new one is much better!
Thanks for this excellent answer. Is there a way to read in only the latest Number in the top row when readtable() fetches the data, without doing the extraction in Matlab table?
I want to read in the latest data from a table, which is updated daily.
Christopher Creutzig
il 27 Gen 2025
You can use DataRows=[1,1] to only read from the first row.
Note: The count here does not start where the import without the option starts. Depending on the data, you may have better luck with DataRows=[2,2] or something like that.
Why not just DataRows=2? Because by backward compatibility with other related options in readtable, DataRows=2 means “data rows start at n=2.”
Categorie
Scopri di più su Tables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!