You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for the amazing package! I have an importing issue---I'm sure I'm doing something silly, but I can't quite figure it out. Both read_fwf and vroom_fwf are producing files that lack one line (the first line, to be precise) when importing fixed-width files. Edit: it only does this when n_max is specified as a value other than Inf, or when the file is a local file in a Windows machine: see Stack Overflow post here.
This will only produce one row of data. But there are two lines in this raw file, as evidenced by
writeLines(read_lines(path)) ## two lines
which produces two lines as expected. If I leave only one line in the raw data, it'll produce zero imported rows.
Now, if n_max = Inf as in the default, it's fine:
## gives two lines as it should
vroom::vroom_fwf(
"vroom_fwf_test.txt", fwf_widths(test$V3, test$V1),
n_max = Inf, col_types = cols(.default = "c"), id = "file_name"
)
Even with n_max = 1000 specified, the following works fine, too: the original files have been uploaded to GitHub and are being directly called from there:
## gives two lines as it should
vroom::vroom_fwf(
file = "https://github.com/tidyverse/vroom/files/12156789/vroom_fwf_test.txt",
col_positions = with(
read.csv(
"https://github.com/tidyverse/vroom/files/12156786/test.csv",
header = F
), vroom::fwf_widths(V3, V1)
),
n_max = 1000,
col_types = vroom::cols(.default = "c"),
id = "file_name"
)
I am not sure where I've gone wrong. They are literally the same files, and I've checked that col_positions is not the problem. Perhaps it is a line-ending issue? My session info is as follows:
Hello team,
Thank you for the amazing package! I have an importing issue---I'm sure I'm doing something silly, but I can't quite figure it out. Both
read_fwf
andvroom_fwf
are producing files that lack one line (the first line, to be precise) when importing fixed-width files. Edit: it only does this whenn_max
is specified as a value other thanInf
, or when the file is a local file in a Windows machine: see Stack Overflow post here.There are two files:
Suppose that the fixed-width file and the CSV file are at the root directory. The code I used is (a part of a larger codebase)
This will only produce one row of data. But there are two lines in this raw file, as evidenced by
which produces two lines as expected. If I leave only one line in the raw data, it'll produce zero imported rows.
Now, if
n_max = Inf
as in the default, it's fine:Even with
n_max = 1000
specified, the following works fine, too: the original files have been uploaded to GitHub and are being directly called from there:I am not sure where I've gone wrong. They are literally the same files, and I've checked that
col_positions
is not the problem. Perhaps it is a line-ending issue? My session info is as follows:Has anybody encountered a similar problem? Thank you very much.
The text was updated successfully, but these errors were encountered: