Skip to content
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
Closed

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

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

Comments

@Pablo-Leon
Copy link

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
Copy link
Collaborator

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

@Pablo-Leon
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

thanks!

@mr-majkel
Copy link

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?

@lock
Copy link

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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants