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

Get write_lines() to write Windows new lines (CRLF) #665

Closed
Pablo-Leon opened this Issue May 4, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@Pablo-Leon

Pablo-Leon commented May 4, 2017

I'm aware of Issue #87 on read_csv(), and it's correct that write functions use the same terminator, but sometimes you need to write a file for another program, that only understands CRLF lines.

So I would like to be able to specify a CRLF line terminator as an option on write functions.

Meanwhile, the hackish way :
> write_lines(paste0(vData, "\r"), filePath))

Thanks for the great package.

  • Pablo
@jimhester

This comment has been minimized.

Member

jimhester commented May 4, 2017

I think just using base::writeLines() would be the way to go if you really want CRLF terminated lines.

@Pablo-Leon

This comment has been minimized.

Pablo-Leon commented May 4, 2017

Haha , forgot about base::* !

But base::writeLines() lack an EOL parameter so it will work while running on windows, not in linux.
Keeping my hack 'cause it works and is still faster (33%).

thanks

  • Pablo
@jimhester

This comment has been minimized.

Member

jimhester commented May 4, 2017

You can do the following to work the same regardless of platform.

con <- file("xyz", mode = "wb")
writeLines(x, sep = "\r\n")
close(con)
@Pablo-Leon

This comment has been minimized.

Pablo-Leon commented May 4, 2017

thanks!

jimhester added a commit that referenced this issue May 4, 2017

@mr-majkel

This comment has been minimized.

mr-majkel commented Oct 23, 2017

Hi, @jimhester if I may suggest something - I would not use "sep" name for argument about end of line mark. "sep" is traditionally used in base R functions to state what is a separator between columns. Maybe we could "eol" instead?

jimhester added a commit that referenced this issue Dec 6, 2017

jimhester added a commit that referenced this issue Dec 6, 2017

@lock

This comment has been minimized.

lock bot commented Sep 25, 2018

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/

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.