Skip to content

"embedded nul in string" Issue reading GTFS files downloaded or saved on MacOS #217

@ttalVlatt

Description

@ttalVlatt

Hi there,

When macOS downloads files, it adds attributes for security etc. that seem to throw off fread() call used in this package. For instance, a common thing macOS adds when you download a file from the internet, such as from mobilitydatabase.org is the com.apple.quarantine. When you try and read a GTFS file that has this, you get this error.

Error in data.table::fread(fs::path(tmpdir, filename), nrows = 1, colClasses = "character") : 
  embedded nul in string: '\005\026\a\0\002\0\0Mac OS X        \0\002\0\0\0\t\0\0\02\0\0\0\xa2\0\0\0\002\0\0\0\xd4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ATTR\0\0\0\0\0\0\0\xd4\0\0\0\x98\0\0\0<\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\001\0\0\0\x98\0\0\0<\0\0\025com.apple.quarantine\0q/0083'

You can remove those by hand with xattr -dr com.apple.quarantine minneapolis-metro-transit. But even if that's removed you get

Error in data.table::fread(fs::path(tmpdir, filename), nrows = 1, colClasses = "character") : 
  embedded nul in string: '\005\026\a\0\002\0\0Mac OS X        \0\002'

I played around trying pass different encoding options to fread() but none of them seemed to work. Based off this stack overflow there seem to be a few workarounds, but none I can think of easily implementing here. Any ideas?

I don't if they will be much help if you're not on macOS, but I attached files with the problematic attributes here.

minneapolis-mvta-gtfs.zip

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