How do I extract the contents of an HTML table on a web page into a MATLAB table?
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (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 comentarios
Bucks Lin
el 14 de Abr. de 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
el 27 de En. de 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.”
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!