Skip to content

Line endings with read.csv.sql #52

Open
@ggrothendieck

Description

@ggrothendieck

When using read.csv.sql if there are problems with the last column in the input that increases the chance that there are end of line problems.

read.csv.sql has an eol= argument which can specify the end of line character(s). It is automatically set to \r\n on Windows and \n otherwise but a file can have non-default line endings. One can check the line endings of a file using this from the shell or Windows cmd line (not from R):

file myfile

Another potential problem is a missing eol character(s) on the last line. This can be checked with the following which will return a number greater than 0 if there is a eol on the last line.

tail -c1 myfile | wc -l 

On Windows these commands can be found in C:\Rtools42\usr\bin if Rtools for R 4.2 is installed. See https://cran.r-project.org/bin/windows/Rtools/

On Linux the unix2dos and dos2unix (or on some systems fromdos and todos) can convert line endings. On Windows binaries are available at https://waterlan.home.xs4all.nl/dos2unix.html .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions