CSVFiles: read file with non-standard extension

I’m trying to use CSVFiles.jl to read a .tsv file that has a non-standard file extension (which cannot easily be changed).

The readme suggests

df = DataFrame(load(Stream(format"CSV", io)))

But trying to apply this pattern results in the following error:

path  = "/file/tree/my_nonstandard_file.1b"
f = open(path)
df = load(Stream(format"CSV", f)) |> DataFrame
head(df)

What am I doing wrong here?

(By the way, I know there are alternatives (CSV.jl, DelimitedFiles etc.), but I would like to make CSVFiles work in this case)

( I am not tested )

but, based on the : https://github.com/queryverse/CSVFiles.jl/blob/master/test/runtests.jl#L128
can you test with

  • fileiostream = FileIO.Stream(FileIO.format"TSV", stream)

so with: format"TSV"

1 Like

Seems to be a bug in TextParse.jl: just use String(read(f)), not String(Mmap.mmap(f)) by stevengj · Pull Request #86 · queryverse/TextParse.jl · GitHub

3 Likes

Unfortunately does not work either.

I see, then I’ll wait for the merge. Thanks!

1 Like

Can you try

using CSVFiles, DataFrames, FileIO

path  = "/file/tree/my_nonstandard_file.1b"
df = load(File(format"TSV", path)) |> DataFrame
2 Likes

Works like a charm! Maybe this could be reflected in the README.md of CSVfiles.

1 Like

https://github.com/queryverse/CSVFiles.jl/issues/36

4 Likes