Skip to content

🐛 fix loading CSV ‘books’ if the path contains ‘.’ #47

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyexcel_io/readers/csvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def _load_from_file(self):
self.__line_terminator = self._keywords.get(
constants.KEYWORD_LINE_TERMINATOR,
self.__line_terminator)
names = self._file_name.split('.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we do this: os.path.abspath(self._file_name), which then expands both '.' and '..' into absolute path? And maybe we could do os.path.splitext()..?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, neither pyexcel nor pyexcel-io currently refer to os.path.abspath(), and using it in this case seems like overkill. In my opinion, using os.path.splitext() is most correct, although it requires changing two lines below. Would you rather I submit that change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's choose the most correct change - os.path.splitext(). I will write a few test cases later.

names = self._file_name.rsplit('.', 1)
filepattern = "%s%s*%s*.%s" % (
names[0],
constants.DEFAULT_MULTI_CSV_SEPARATOR,
Expand Down