How to use the visidata.status function in visidata

To help you get started, we’ve selected a few visidata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saulpw / visidata / visidata / loaders.py View on Github external
def load_tsv(vs):
    'populates vs with the parsed tsv text in contents.'
    header_lines = int(options.csv_headerlines or 0)
    lines = vs.contents.splitlines()
    if lines:
        rows = [L.split('\t') for L in lines]
        if header_lines:
            # columns ideally reflect the max number of fields over all rows
            vs.columns = ArrayNamedColumns('\\n'.join(x) for x in zip(*rows[:header_lines]))
        else:
            vs.columns = ArrayColumns(len(rows[0]))

        vs.rows = rows[header_lines:]
        status('lines (lines=%d, )' % len(vs.columns))
    else:
        status('no lines (len %d)' % len(vs.columns))
    return vs
github saulpw / visidata / visidata / saving.py View on Github external
def commitAdds(self):
    nadded = 0
    for row in self._deferredAdds.values():
        try:
            self.addSourceRow(row)
            nadded += 1
        except Exception as e:
            exceptionCaught(e)

    if nadded:
        status('added %s %s' % (nadded, self.rowtype))

    self._deferredAdds.clear()
    return nadded
github saulpw / visidata / visidata / Sheet.py View on Github external
def findColIdx(self, colname, columns=None):
        if columns is None:
            columns = self.columns
        cols = list(colidx for colidx, c in enumerate(columns) if c.name == colname)
        if not cols:
            error('no column named "%s"' % colname)
        elif len(cols) > 1:
            status('%d columns named "%s"' % (len(cols), colname))
        return cols[0]
github saulpw / visidata / visidata / loaders / tsv.py View on Github external
def save_tsv(p, vs):
    'Write sheet to file `fn` as TSV.'
    delim = options.get('delimiter', vs)
    trdict = tsv_trdict(vs)

    save_tsv_header(p, vs)

    with p.open_text(mode='a') as fp:
        for dispvals in genAllValues(vs.rows, vs.visibleCols, trdict, format=True):
            fp.write(delim.join(dispvals))
            fp.write('\n')

    status('%s save finished' % p)
github saulpw / visidata / visidata / loaders.py View on Github external
def open_py(p):
    contents = getTextContents(p)
    exec(contents, vdglobals())
    status('executed %s' % p)
github saulpw / visidata / plugins / defermods.py View on Github external
def commitAdds(self):
    nadded = 0
    for row in self._deferredAdds.values():
        try:
            self.addSourceRow(row)
            nadded += 1
        except Exception as e:
            exceptionCaught(e)

    if nadded:
        status('added %s %s' % (nadded, self.rowtype))

    self._deferredAdds.clear()
    return nadded
github saulpw / visidata / visidata / loaders.py View on Github external
Column('type', str, lambda r: type(r).__name__),
                Column('nItems', int, lambda r: len(r)),
            ]
            self.command('^J', 'vd.push(SheetH5Obj(name+options.SubsheetSep+cursorRow.name, cursorRow, source))', 'open this group or dataset')
            self.command('A', 'vd.push(SheetDict(cursorRow.name + "_attrs", cursorRow.attrs))', 'open metadata sheet for this object')
        elif isinstance(self.hobj, h5py.Dataset):
            if len(self.hobj.shape) == 1:
                self.rows = self.hobj[:]  # copy
                self.columns = [ColumnItem(colname, colname) for colname in self.hobj.dtype.names]
            elif len(self.hobj.shape) == 2:  # matrix
                self.rows = self.hobj[:]  # copy
                self.columns = ArrayColumns(self.hobj.shape[1])
            else:
                status('too many dimensions in shape %s' % str(self.hobj.shape))
        else:
            status('unknown h5 object type %s' % type(self.hobj))
github saulpw / visidata / visidata / Sheet.py View on Github external
def unselect(self, rows):
        rows = list(rows)
        before = len(self._selectedRows)
        for r in rows:
            if id(r) in self._selectedRows:
                del self._selectedRows[id(r)]
        status('unselected %s/%s rows' % (before-len(self._selectedRows), len(rows)))
github saulpw / visidata / visidata / loaders / json.py View on Github external
def reload(self):
        self.colnames = {}  # [colname] -> Column
        self.columns.clear()

        if not self.jsonlines:
            try:
                self.reload_json()
            except ValueError as e:
                status('trying jsonl')
                self.jsonlines = True

        if self.jsonlines:
            self.reload_jsonl()
github saulpw / visidata / visidata / Sheet.py View on Github external
def skipUp(self):
        pv = self.cursorValue
        for i in range(self.cursorRowIndex, -1, -1):
            if self.cellValue(i, self.cursorColIndex) != pv:
                self.cursorRowIndex = i
                return

        status('no different value up this column')