Extract tabular data in comma-separated or tab-separated format from a response body.
Arguments
- resp
(
httr2_response) A singlehttr2::response()object (as returned byhttr2::req_perform()).- check_type
(
length-1 logical) Whether to check that the response has the expected content type. Set toFALSEif the response is not specifically tagged as the proper type.
Examples
resp_csv <- httr2::response(
headers = list("Content-Type" = "text/csv"),
body = charToRaw("a,b\n1,2\n3,4")
)
resp_body_csv(resp_csv)
#> a b
#> 1 1 2
#> 2 3 4
resp_tsv <- httr2::response(
headers = list("Content-Type" = "text/tab-separated-values"),
body = charToRaw("a\tb\n1\t2\n3\t4")
)
resp_body_tsv(resp_tsv)
#> a b
#> 1 1 2
#> 2 3 4