reader

package
v0.0.0-...-41d0e0c Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateDummyGradeNames

func GenerateDummyGradeNames(thatMany int) (grades []string, err error)

GenerateDummyGradeNames generates dummy grade names in reverse alphabetical order

func ReadNamesRow

func ReadNamesRow(row []string, skipFirst bool) (names []string)

ReadNamesRow reads a bunch of names as strings

func ReadNumber

func ReadNumber(s string) (n float64, err error)

ReadNumber reads the number from the input string.

func ReadTallyRow

func ReadTallyRow(row []string, skipFirst bool) ([]float64, error)

ReadTallyRow reads a proposal tally row from strings

Types

type ProfilesCsvReader

type ProfilesCsvReader struct{}

ProfilesCsvReader reads a poll's tally in a CSV like so:

Nutriscore, G, F, E, D, C, B, A
     Pizza, 4, 2, 3, 4, 5, 4, 1
     Chips, 5, 3, 2, 4, 4, 3, 2
     Pasta, 4, 4, 2, 4, 4, 3, 2

func (ProfilesCsvReader) Read

func (r ProfilesCsvReader) Read(input *io.Reader) (
	judgments [][]int,
	tallies [][]float64,
	proposals []string,
	grades []string,
	err error,
)

Read the input CSV and return as much data as we can. Read does not fill the `judgments` because this data is absent from the profiles.

type Reader

type Reader interface {
	// Read the input into judgment and tally data, as well as poll metadata.
	// Most outputs are allowed to be empty (nil?),
	// but you must return at least either `tallies` or `judgments`.
	Read(
		input *io.Reader,
	) (
		judgments [][]int,
		tallies [][]float64,
		proposals []string,
		grades []string,
		err error,
	)
}

Reader to implement to make another reader

Jump to

Keyboard shortcuts

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