Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CLI csvlint doesn't handle filenames with spaces #182

Closed
ryanfb opened this issue Feb 23, 2016 · 3 comments
Closed

CLI csvlint doesn't handle filenames with spaces #182

ryanfb opened this issue Feb 23, 2016 · 3 comments

Comments

@ryanfb
Copy link

ryanfb commented Feb 23, 2016

Raises URI::InvalidURIError:

$ csvlint Harpokration\ CITE\ Translation.csv
/Users/ryan/.rbenv/versions/2.3.0/lib/ruby/2.3.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): file:/Users/ryan/source/dc3/harpo/harpokration-data/Harpokration CITE Translation.csv (URI::InvalidURIError)
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/2.3.0/uri/rfc3986_parser.rb:73:in `parse'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/2.3.0/uri/rfc3986_parser.rb:117:in `convert_to_uri'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/2.3.0/uri/rfc3986_parser.rb:88:in `join'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/2.3.0/uri/common.rb:265:in `join'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/validate.rb:460:in `block in locate_schema'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/validate.rb:456:in `each'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/validate.rb:456:in `locate_schema'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/validate.rb:94:in `validate'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/validate.rb:86:in `initialize'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/cli.rb:130:in `new'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/cli.rb:130:in `validate_csv'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/lib/csvlint/cli.rb:18:in `validate'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/csvlint-0.3.0/bin/csvlint:9:in `<top (required)>'
        from /Users/ryan/.rbenv/versions/2.3.0/bin/csvlint:23:in `load'
        from /Users/ryan/.rbenv/versions/2.3.0/bin/csvlint:23:in `<main>'
$ cp Harpokration\ CITE\ Translation.csv test.csv
$ csvlint test.csv
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
test.csv is VALID
1. inconsistent_values. Column: 7
@Floppy
Copy link
Member

Floppy commented Aug 15, 2017

If I run https://raw.githubusercontent.com/theodi/octopub/fix-whitespace-files/spec/fixtures/file with whitespace.csv through the CSVlint website, it doesn't do anything. So, I suspect something is failing. However, running it through properly encoded (https://raw.githubusercontent.com/theodi/octopub/fix-whitespace-files/spec/fixtures/file%20with%20whitespace.csv) is fine.

@Floppy
Copy link
Member

Floppy commented Aug 15, 2017

The issue here is that file URLs on the input aren't being properly URL-encoded before being passed into whatever loads them. That's similar to the fix I've applied in theodi/octopub#567.

@Floppy
Copy link
Member

Floppy commented Aug 15, 2017

Confirmed that the same URI error happens with the url with spaces in csvlint.io.

@Floppy Floppy self-assigned this Aug 15, 2017
Floppy added a commit that referenced this issue Aug 15, 2017
File paths can contain spaces. URIs cannot. Paths must therefore be encoded before turning into URIs. Fixes #182.
Floppy added a commit that referenced this issue Aug 15, 2017
File paths can contain spaces. URIs cannot. Paths must therefore be encoded before turning into URIs. Fixes #182.
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants