Skip to content

melt_tsv "inserts" a new line with CRLF #13

@lymanmark

Description

@lymanmark

I've been working with a set of ragged files, and of course one of them has to be different. Most have only the "\n" EOL character while one has "\r\n". melt_tsv seems to recognize both and essentially inserts a new line.

library(meltr)

# melt_tsv appears to treat \r and \n as seperate eol characters
# Thus "b" gets bumped to row 3
melt_tsv("a\t\r\nb\t")
#> # A tibble: 5 × 4
#>     row   col data_type value
#>   <dbl> <dbl> <chr>     <chr>
#> 1     1     1 character a    
#> 2     1     2 missing   <NA> 
#> 3     2     1 missing   <NA> 
#> 4     3     1 character b    
#> 5     3     2 missing   <NA>
# With only \n as eol "b" is on row 2
melt_tsv("a\t\nb\t")
#> # A tibble: 4 × 4
#>     row   col data_type value
#>   <dbl> <dbl> <chr>     <chr>
#> 1     1     1 character a    
#> 2     1     2 missing   <NA> 
#> 3     2     1 character b    
#> 4     2     2 missing   <NA>
# It also seems to be fine with no missing values
melt_tsv("a\tc\r\nb\td")
#> # A tibble: 4 × 4
#>     row   col data_type value
#>   <dbl> <dbl> <chr>     <chr>
#> 1     1     1 character a    
#> 2     1     2 character c    
#> 3     2     1 character b    
#> 4     2     2 character d

Created on 2024-05-31 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions