csv_to_gorm

package module
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 11 Imported by: 1

README

csv_to_gorm

A utility to read a csv file into a gorm managed database or, more generally, into a slice of structs.

usage

Acknowledgements

This module was developed as part of a section of work undertaken for Emerald Operating Partners LLC, who have kindly agreed to its release as open source under the MIT licence.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CsvToSlice

func CsvToSlice(file *os.File, colSep rune, model interface{}, colMap map[string]int) interface{}

converts the content of a CSV file to a slice of 'models' colMap maps the feldnames of the model to the column numbers (beginning at 1) of the CSV file the result is an interface, which will need to be typecast by the caller

func ExcelColIdToColNo

func ExcelColIdToColNo(colID string) (int, error)

func ExcelColNoToColId

func ExcelColNoToColId(colNo int) (string, error)

func GetDbFields

func GetDbFields(model interface{}) ([]string, error)

func GetHeadings

func GetHeadings(file *os.File, colSep rune) ([]string, error)

func GuessSeparator

func GuessSeparator(file *os.File) (rune, error)

inputReader would normally be the file or stream to read

func StringToType

func StringToType(input string, outType reflect.Type) reflect.Value

takes the text string of a CSV field and converts it to a reflect.Value of a given type (supplied as a reflect.Type) used internally, but exposed as it may have uses elsewhere

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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