Small description
When opening VisiData from a REPL using visidata.view() or visidata.view_pandas(), errors evaluating the sheet.name property prevent VisiData from loading properly.
Expected result
VisiData can be used from a REPL to view arbitrary Python objects with visidata.view(), or Pandas DataFrames with visidata.view_pandas().
Actual result with screenshot
Error invoking visidata.view_pandas():
~/code/visidata/visidata/basesheet.py in name(self)
142 if self._name:
143 return self._name
--> 144 if not self.source:
145 return ''
146 return self.source.name + '_'+self.rowtype
~/.pyenv/versions/3.8.0/envs/vd-dev/lib/python3.8/site-packages/pandas/core/generic.py in __nonzero__(self)
1550
1551 def __nonzero__(self):
-> 1552 raise ValueError(
1553 "The truth value of a {0} is ambiguous. "
1554 "Use a.empty, a.bool(), a.item(), a.any() or a.all().".format(
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Error invoking visidata.view() (tested with similar results against lists, dicts, and lists of dicts):
~/code/visidata/visidata/basesheet.py in name(self)
144 if not self.source:
145 return ''
--> 146 return self.source.name + '_'+self.rowtype
147
148 @name.setter
AttributeError: 'list' object has no attribute 'name'
Steps to reproduce with sample data and a .vd
From a Python REPL in an environment with VisiData installed from develop (tested against commit 5b72a2cdc77ff21e3dc0dbd8e8a11bfed5de911e):
import visidata
import pandas as pd
obj = [{'col1': 10, 'col2': 'fish', 'col3': True}]
visidata.view(obj)
visidata.view_pandas(pd.DataFrame(obj))
Additional context
Please include the version of VisiData.
2.-3dev (commit 5b72a2cdc77ff21e3dc0dbd8e8a11bfed5de911e)
Note that the view/view_pandas functionality is related to #470. And in case it's useful, here is some historical context around recent changes to sheet.name that seems relevant here:
9c00900a7ae5a267d6085b62c72f42cb724e758b
https://github.com/saulpw/visidata/pull/436
https://github.com/saulpw/visidata/issues/432
I want a label for bug reports that are works of art.
When opening VisiData from a REPL using
visidata.view()orvisidata.view_pandas(),
When you what now ?!!?
you can DO that ?!?!
Haha @sfranky I had the same reaction, I just learned about that feature yesterday!
if not self.source could probably be if self.source is None.
Fixed in #472, thanks to @ajkerrigan!
Most helpful comment
When you what now ?!!?
you can DO that ?!?!