Learn R Programming

BLSloadR (version 0.2)

read_bls_text: Read Plain Text Files from BLS Website

Description

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.

Usage

read_bls_text(url)

Value

A character vector where each element is one line from the text file. Lines are split on newline characters (\n).

Arguments

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/).

Details

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).

See Also

bls_overview for formatted database overviews, load_bls_dataset for loading complete datasets

Examples

Run this code
# \donttest{
# 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)
# }

Run the code above in your browser using DataLab