View source: R/read_bls_text.R
| read_bls_text | R Documentation |
Downloads and reads plain text files from the Bureau of Labor Statistics (BLS)
website. This is a companion function to fread_bls() that handles text
files rather than structured data tables. The function uses custom headers to
ensure reliable access to BLS resources.
read_bls_text(url)
url |
A character string specifying the full URL to a text file on the BLS website (e.g., https://download.bls.gov/pub/time.series/). |
This function is designed to read descriptive text files from BLS, such as README files or database overview documents. It sends an HTTP GET request with browser-like headers to ensure compatibility with BLS server requirements.
The function will stop with an error if the HTTP request fails (e.g., if the URL is invalid or the server is unavailable).
A character vector where each element is one line from the text file.
Lines are split on newline characters (\n).
bls_overview for formatted database overviews,
load_bls_dataset for loading complete datasets
# Read the overview file for Current Employment Statistics
ces_overview <- read_bls_text(
"https://download.bls.gov/pub/time.series/ce/ce.txt"
)
# Display the first few lines
head(ces_overview)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.