Skip to content

Instantly share code, notes, and snippets.

@epoz
Created March 13, 2021 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epoz/0ece001049ace14da15ff21163628cb9 to your computer and use it in GitHub Desktop.
Save epoz/0ece001049ace14da15ff21163628cb9 to your computer and use it in GitHub Desktop.
Textbase loader for visidata.org
from visidata import Column, TableSheet
def open_dmp(p):
return TextBaseSheet(p.name, source=p)
class TextBaseSheet(TableSheet):
rowtype = "records" # rowdef: a list, of collections.OrderedDict objects
def iterload(self):
import textbase
for line in textbase.parse(self.source.given):
for col in line:
c = Column(
col, getter=lambda col, row: "\n".join(row[0].get(col.name, []))
)
if c not in self.columns:
self.addColumn(c)
yield [line]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment