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

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

Closed
wants to merge 1 commit into from

Conversation

danchr
Copy link

@danchr danchr commented Feb 26, 2018

The CSV book reader erronously split the path by all dots, instead
of just the last one. This is what os.path.splitext() is for, but
since it drops the leading dot, I kept the split() call to keep the
change minimal.

I tried to create a testcase for this, but it turned out to be harder than expected since I don't quite understand the internal design of pyexcel.

The CSV book reader erronously split the path by _all_ dots, instead
of just the last one. This is what os.path.splitext() is for, but
since it drops the leading dot, I kept the split() call to keep the
change minimal.
@codecov-io
Copy link

codecov-io commented Feb 26, 2018

Codecov Report

Merging #47 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #47   +/-   ##
=======================================
  Coverage   97.08%   97.08%           
=======================================
  Files          42       42           
  Lines        2951     2951           
=======================================
  Hits         2865     2865           
  Misses         86       86
Impacted Files Coverage Δ
pyexcel_io/readers/csvr.py 98.1% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b53c16...f93d133. Read the comment docs.

@chfw
Copy link
Member

chfw commented Feb 26, 2018

OK. I will have a look.

Here is the overall architecture: http://pyexcel.readthedocs.io/en/latest/architecture.html. You are welcome to ask more questions.

@@ -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.

danchr added a commit to OS2mo/os2mo that referenced this pull request Feb 27, 2018
@chfw chfw closed this May 2, 2018
danchr added a commit to OS2mo/os2mo that referenced this pull request May 3, 2018
The 0.5.7 release of pyexcel-io fixes loading CSV files from
directories containing '.' in their name, which was the motivation for
our fork.

See also <pyexcel/pyexcel-io#47>.
@danchr danchr deleted the fix-dot-books branch May 3, 2018 09:33
@danchr danchr restored the fix-dot-books branch May 3, 2018 09:41
cmoesgaard pushed a commit to OS2mo/os2mo that referenced this pull request May 7, 2018
The 0.5.7 release of pyexcel-io fixes loading CSV files from
directories containing '.' in their name, which was the motivation for
our fork.

See also <pyexcel/pyexcel-io#47>.
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

Successfully merging this pull request may close these issues.

3 participants