csvout

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package csvout writes tables as CSV (RFC 4180): a header row, then one row per item, quoted where a cell needs it.

Every cell is neutralised against CSV injection first. A spreadsheet reads a cell that starts with =, +, -, @, a tab or a carriage return as a formula, so a host alias or a file name chosen by someone else could run one when the export is opened. Such a cell is written with a leading apostrophe, which spreadsheets show as text and strip.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cell

func Cell(v string) string

Cell is one value made safe to open in a spreadsheet.

func Write

func Write(w io.Writer, t Table) error

Write writes t to w as CSV.

Types

type Table

type Table struct {
	Header []string
	Rows   [][]string
}

Table is a header and its rows.

func Parse

func Parse(text string) (Table, error)

Parse reads CSV text with a header row into a Table, so a file produced elsewhere (the Termius export) can be filtered the same way.

func (Table) Column

func (t Table) Column(names ...string) int

Head returns t with at most n rows. Column is the index of the first column named one of names, or -1.

func (Table) Drop

func (t Table) Drop(names ...string) Table

Drop returns t without the named columns. A name that is not a column is ignored, so a saved choice survives a column being renamed or removed.

func (Table) Head

func (t Table) Head(n int) Table

func (Table) Only

func (t Table) Only(col int, values []string) Table

Only keeps the rows whose column col holds one of values; with no values, or no such column, it keeps every row.

func (Table) Without

func (t Table) Without(text string) Table

Without returns t without the rows in which any cell contains text, ignoring case. An empty text keeps every row.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL