leograba / leograba/spinparse

cmdline_parse.py: check if file exist

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

If file passed as input to tesouro_direto.py does not exist, it generates a rather cryptic error:

[leonardo@leo spinparse]$ ./spinparse/parser/tesouro_direto.py -i 2019-12.xls
Traceback (most recent call last):
  File "./spinparse/parser/tesouro_direto.py", line 92, in <module>
    td.to_csv(args.input, args.outpath)
  File "./spinparse/parser/tesouro_direto.py", line 74, in to_csv
    self._preprocess(fname, full_out_fpath, "csv")
  File "./spinparse/parser/tesouro_direto.py", line 68, in _preprocess
    self._parse_in_contents()
  File "./spinparse/parser/tesouro_direto.py", line 52, in _parse_in_contents
    dfs = pd.read_html(self._full_in_fname, skiprows=1)
  File "/usr/lib/python3.8/site-packages/pandas/io/html.py", line 1090, in read_html
    return _parse(
  File "/usr/lib/python3.8/site-packages/pandas/io/html.py", line 912, in _parse
    raise_with_traceback(retained)
  File "/usr/lib/python3.8/site-packages/pandas/compat/__init__.py", line 47, in raise_with_traceback
    raise exc.with_traceback(traceback)
ValueError: No tables found

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at spinparse/parser/tesouro_direto.py, following the -i input from the command-line entry point into to_csv and _preprocess. Reproduce the shown command with a missing file and make the resulting error identify the missing input instead of reaching pandas.read_html; confirm the behavior with the same invocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.