I'm processing a number of csvs in a single script, and sometimes csvs will be empty, which causes a StopIteration exception. This is not serious, but I think it would be helpful if one or more of the following happened:
- This simply be documented: people should know that this happens so they can wrap the section in a try catch block
- The exception should be caught and re-passed with a more intuitive name, something like InvalidFile
- A new flag should be added/old flag expanded to optionally silence the exception and return an empty array
Reproducing code example:
import numpy as np
import os
inFile = "/tmp/example.csv"
os.system(f"touch {inFile}")
my_data = np.genfromtxt(inFile, delimiter=',', skip_header=1, invalid_raise=false)
Error message:
Traceback (most recent call last):
File "", line 1, in
File "/#####/lib/python3.6/site-packages/numpy/lib/npyio.py", line 1780, in genfromtxt
next(fhd)
StopIteration
Numpy/Python version information:
1.17.0 3.6.3 (default, Apr 24 2018, 18:36:28)
[GCC 4.7.2]
I'm processing a number of csvs in a single script, and sometimes csvs will be empty, which causes a StopIteration exception. This is not serious, but I think it would be helpful if one or more of the following happened:
Reproducing code example:
Error message:
Traceback (most recent call last):
File "", line 1, in
File "/#####/lib/python3.6/site-packages/numpy/lib/npyio.py", line 1780, in genfromtxt
next(fhd)
StopIteration
Numpy/Python version information:
1.17.0 3.6.3 (default, Apr 24 2018, 18:36:28)
[GCC 4.7.2]