added cleanup for number_convert to address errors #122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The Insider.get_insider function is failing in util.py with this error:
File "h:\anaconda3\lib\site-packages\finvizfinance\insider.py", line 88, in get_insider
info_dict[table_header[i]] = number_covert(col.text)
File "h:\anaconda3\lib\site-packages\finvizfinance\util.py", line 148, in number_covert
elif num[-1] == "%":
IndexError: string index out of range
Type of change
What you did
Changes Made:
How This Fixes the Problem:
The if not num check ensures that the function won't try to access the last character of an empty string, thus avoiding the IndexError.
If num is "%", "B", "M", or "K", the function properly processes the string and converts it to the corresponding float.
If num is just a plain number with commas, it will remove the commas and convert the number to a float.