From 3c2089d6d9ce091c8fbb3f8b000226b3fd7324bb Mon Sep 17 00:00:00 2001 From: Benjamin Schwendinger Date: Fri, 9 Jan 2026 10:07:52 +0100 Subject: [PATCH 1/3] use yaml struct to pass n_read --- R/fread.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/fread.R b/R/fread.R index 2f397b78e..bc8509c71 100644 --- a/R/fread.R +++ b/R/fread.R @@ -182,7 +182,9 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC") call_args = names(match.call()) if (is.character(skip)) warningf("Combining a search string as 'skip' and reading a YAML header may not work as expected -- currently, reading will proceed to search for 'skip' from the beginning of the file, NOT from the end of the metadata; please file an issue on GitHub if you'd like to see more intuitive behavior supported.") - yaml_header = .read_yaml_header(input, skip, verbose) + yaml_res = .read_yaml_header(input, skip, verbose) + yaml_header = yaml_res$yaml_header + n_read = yaml_res$n_read yaml_names = names(yaml_header) # process header first since it impacts how to handle colClasses if ('header' %chin% yaml_names) { @@ -387,7 +389,7 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC") yaml_header = yaml::yaml.load(yaml_string) if (verbose) catf('Processed %d lines of YAML metadata with the following top-level fields: %s\n', n_read, brackify(names(yaml_header))) - yaml_header + list(yaml_header = yaml_header, n_read = n_read) } # nocov end. From 4e047bb544634c99e09d81116c94d23c88e97242 Mon Sep 17 00:00:00 2001 From: Benjamin Schwendinger Date: Fri, 9 Jan 2026 10:13:12 +0100 Subject: [PATCH 2/3] add test --- inst/tests/other.Rraw | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/tests/other.Rraw b/inst/tests/other.Rraw index a7c8f4c94..a59b1c604 100644 --- a/inst/tests/other.Rraw +++ b/inst/tests/other.Rraw @@ -258,6 +258,7 @@ if (loaded[["yaml"]]) { # csvy; #1701. Was 2032-2033 in tests.Rraw, #5516 test(16.01, fread(f), DT) ## should be the same, but with yaml_metadata attribute test(16.02, fread(f, yaml = TRUE), DT_yaml) + test(16.025, fread(f, yaml = TRUE, skip = 0L), DT_yaml) ## testing verbose messaging test(16.03, fread(f, yaml = TRUE, verbose = TRUE), DT_yaml, output = 'Processed.*YAML metadata.*') From 8c01c722f83b4ce9ae301f888fb69efe774368f1 Mon Sep 17 00:00:00 2001 From: Benjamin Schwendinger Date: Fri, 9 Jan 2026 10:16:17 +0100 Subject: [PATCH 3/3] remove unnecessary test --- inst/tests/other.Rraw | 1 - 1 file changed, 1 deletion(-) diff --git a/inst/tests/other.Rraw b/inst/tests/other.Rraw index a59b1c604..a7c8f4c94 100644 --- a/inst/tests/other.Rraw +++ b/inst/tests/other.Rraw @@ -258,7 +258,6 @@ if (loaded[["yaml"]]) { # csvy; #1701. Was 2032-2033 in tests.Rraw, #5516 test(16.01, fread(f), DT) ## should be the same, but with yaml_metadata attribute test(16.02, fread(f, yaml = TRUE), DT_yaml) - test(16.025, fread(f, yaml = TRUE, skip = 0L), DT_yaml) ## testing verbose messaging test(16.03, fread(f, yaml = TRUE, verbose = TRUE), DT_yaml, output = 'Processed.*YAML metadata.*')