-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Print column specification with write_csv #895
Comments
I'd like to second this request, but add that it would be nice to not just display the column spec, but return them as first-class objects of some sort. I was thinking of something like:
Thank you for the work and consideration. |
I have also asked this question (as to how others have done this) and posted my local solution here: https://stackoverflow.com/q/55249599/1022967 |
Proposed function / workflow to migrate from base R data frames to readr
|
So you can now generate a column specification from any data.frame with Currently I don't think it makes sense to print the spec out by default, but we can revisit it in a separate issue if needed. |
This is fantastic. Thank you! |
@jimhester You said:
I see that there is a new What I'd really like to do is what you suggest in your post. Take a data frame or its column specification and automatically generate the concise string representation of the column specification. In other words, something like this: |
It was a typo, I meant |
Thanks @jimhester! However, The example in the documentation does convert a concise string representation into a col_spec: |
Yes it does, you need to use the development version of readr. as.character(readr::as.col_spec(mtcars))
#> [1] "ddddddddddd"
packageVersion("readr")
#> [1] '1.3.1.9000' Created on 2019-09-30 by the reprex package (v0.3.0) |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
When a csv created by
write_csv()
is read into another script, it would be helpful to have the column specification already produced as a side-effect of thewrite_csv()
call that produced it.Here's one way that could look.
After
write_csv()
is used, a message is printed with the column specification matching the datatypes of the dataframe that was input towrite_csv()
.This would make it easier to integrate
write_csv()
into a data-processing pipeline that plays nicely with Git.The text was updated successfully, but these errors were encountered: