Skip to content

Unable to open file with hash in filename #174

@mdavis-xyz

Description

@mdavis-xyz

Steps to reproduce

Create a file with a hash in the name.

echo "a,b" >> "test#file.CSV"
echo "1,2" >> "test#file.CSV"

Try to read it with another tool:

head "test#file.CSV"

Now try with tabview (1.4.4)

$ tabview "test#file.CSV"
Traceback (most recent call last):
  File "/home/matthew/Documents/TSE/Internships/IEA/Workload/aws-batch/nemweb-batch/csv2parquet/venv/bin/tabview", line 108, in <module>
    view(data, enc=args.encoding, start_pos=start_pos,
  File "/home/matthew/Documents/TSE/Internships/IEA/Workload/aws-batch/nemweb-batch/csv2parquet/venv/lib/python3.12/site-packages/tabview/tabview.py", line 1301, in view
    with open(parsed_path, 'rb') as fd:
         ^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'test'

Same result with using single quotes or no quotes to escape the file name.

Cause

urlparse will delete the # component, because for http URLs that makes sense. For local files, # doesn't mean anything different to other characters.

Since files are openned with open(parsed_path, 'rb'), it seems like tabview doesn't support reading remote files over http. So what's the point of the urlparse usage?

Solution

Delete the parse_path function. Just keep the filename data string as is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions