Documentation
¶
Index ¶
- func DumpToFile(slice interface{}, path string, options ...CsvOptions) error
- func DumpToString(slice interface{}, options ...CsvOptions) (string, error)
- func DumpToWriter(slice interface{}, writer io.Writer, options ...CsvOptions) error
- func LoadFromPath(path string, destination interface{}, options ...CsvOptions) error
- func LoadFromReader(file io.Reader, destination interface{}, options ...CsvOptions) error
- func LoadFromString(str string, destination interface{}, options ...CsvOptions) error
- type CsvOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpToFile ¶
func DumpToFile(slice interface{}, path string, options ...CsvOptions) error
DumpToFile - writes a slice content into a file specified by path. @param slice: An object typically of the form []struct, where the struct is using csv tag. @param path: The file path string of where you want the file to be created. @param options (optional): options for the csv parsing. @return an error if one occures.
func DumpToString ¶
func DumpToString(slice interface{}, options ...CsvOptions) (string, error)
DumpToString - writes a slice content into a string. @param slice: An object typically of the form []struct, where the struct is using csv tag. @param options (optional): options for the csv parsing. @return a string and an error if one occures.
func DumpToWriter ¶
func DumpToWriter(slice interface{}, writer io.Writer, options ...CsvOptions) error
DumpToWriter - writes a slice content into an io.Writer. @param slice: an object typically of the form []struct, where the struct is using csv tags. @param writer: the location of where you will write the slice content to. Example: File, Stdout, etc. @param options (optional): options for the csv parsing. @return an error if one occures.
func LoadFromPath ¶
func LoadFromPath(path string, destination interface{}, options ...CsvOptions) error
LoadFromPath - Load csv from a path and put it in a array of the destination's type using tags. Example:
tabOfMyStruct := []MyStruct{} err := Load( "my_csv_file.csv", &tabOfMyStruct, CsvOptions{ Separator: ';', Header: []string{"header1", "header2", "header3" } })
@param path: the path of the csv file. @param destination: object where to store the result. @param options (optional): options for the csv parsing. @return an error if one occurs.
func LoadFromReader ¶
func LoadFromReader(file io.Reader, destination interface{}, options ...CsvOptions) error
LoadFromReader - Load csv from an io.Reader and put it in a array of the destination's type using tags. Example:
tabOfMyStruct := []MyStruct{} err := Load( myIoReader, &tabOfMyStruct, CsvOptions{ Separator: ';', Header: []string{"header1", "header2", "header3" } })
@param file: the io.Reader. @param destination: object where to store the result. @param options (optional): options for the csv parsing. @return an error if one occurs.
func LoadFromString ¶
func LoadFromString(str string, destination interface{}, options ...CsvOptions) error
LoadFromString - Load csv from string and put it in a array of the destination's type using tags. Example:
tabOfMyStruct := []MyStruct{} err := Load( myString, &tabOfMyStruct, CsvOptions{ Separator: ';', Header: []string{"header1", "header2", "header3" } })
@param str: the string. @param destination: object where to store the result. @param options (optional): options for the csv parsing. @return an error if one occurs.
Types ¶
type CsvOptions ¶
CsvOptions - options when loading or dumping csv.