When trying to convert csv to sqlite table, get the error "ValueError: max() arg is an empty sequence"
- Dominant language
- Python
- Stars
- 1k
- Forks
- 131
- PR merge metrics
- No merged PRs in 30d
Description
Please see this question on SO:
https://stackoverflow.com/questions/45550070/valueerror-max-arg-is-an-empty-sequence-odo-sqlite3
I have retried this problem using a brand new csv and am still getting the same issue. Code that worked last week now doesn't.
I have gone through the source code and have traced the issue to the `dispatch` function within the `regex.py` file. All of `priority` `funcs.items` `func` and `funcs` variables are empty i.e. have been unassigned.
The following code does not work for me.
#Data:
For a sample file:
"my_table.csv"
City Facebook Total_ads Lat Long
Birmingham training 1338 54 -1.8
Bristol sales 5314 51.45 -2.58
Cambridge it 2141 52.2 -0.12
Hull marketing 3419 53.74 -0.3367
Leeds it 8332 53.8578 -1.5023
Manchester it 5120 53.4808 -2.2426
Newcastle sales 2083 54.9783 -1.6178
Nottingham business 4844 52.9548 -1.1581
Oxford business 6366 51.752 -1.2577
Reading training 8697 51.4543 -0.9781
Sheffield business 4278 53.3811 -1.4701
# Code:
import sqlite3
import pandas as pd
from odo import odo, resource, discover
file_path = 'mypath/'
db_name = 'db1.sqlite'
conn = sqlite3.connect(file_path + db_name)
data_shape = discover(resource(file_path + "my_table.csv"))
odo(pd.read_csv(file_path + "my_table.csv"),
"""sqlite:///mypath/db1.sqlite::table1""", dshape=data_shape)
conn.close()
# End Code
with data_shape:
dshape("""var * {
City: ?string,
Facebook: ?string,
Total_ads: int64,
Lat: float64,
Long: float64
}""")
This fails with the error:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2885, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 4, in
dshape=data_shape)
File "C:\Python27\lib\site-packages\odo\odo.py", line 91, in odo
return into(target, source, **kwargs)
File "C:\Python27\lib\site-packages\multipledispatch\dispatcher.py", line 164, in __call__
return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\odo\into.py", line 43, in wrapped
return f(*args, **kwargs)
File "C:\Python27\lib\site-packages\odo\into.py", line 149, in into_string_string
return into(a, resource(b, **kwargs), **kwargs)
File "C:\Python27\lib\site-packages\multipledispatch\dispatcher.py", line 164, in __call__
return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\odo\into.py", line 43, in wrapped
return f(*args, **kwargs)
File "C:\Python27\lib\site-packages\odo\into.py", line 142, in into_string
a = resource(uri, dshape=resource_ds, expected_dshape=dshape, **kwargs)
File "C:\Python27\lib\site-packages\odo\regex.py", line 91, in __call__
print(funcs)
File "C:\Python27\lib\site-packages\odo\regex.py", line 88, in dispatch
print(priority)
ValueError: max() arg is an empty sequence
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.