Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unable to open file with hash in filename #174

Open
mdavis-xyz opened this issue Oct 6, 2024 · 2 comments
Open

Unable to open file with hash in filename #174

mdavis-xyz opened this issue Oct 6, 2024 · 2 comments

Comments

@mdavis-xyz
Copy link

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.

@firecat53
Copy link
Collaborator

The parse_path function was added because of #164.

@mdavis-xyz
Copy link
Author

Ok, interesting.

Well I think there are two options to handle both file:// and hashes:

  1. urlparse(path)._replace(netloc='', scheme='').geturl()
  2. p=urlparse(path); p.path + p.fragment

Which do you prefer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants