Documentation
¶
Index ¶
Constants ¶
const USE_STD_STREAM string = "-"
USE_STD_STREAM set as filepath string value indicates that standard streams should be used as I/O targets.
Variables ¶
This section is empty.
Functions ¶
func FormatCurrency ¶ added in v0.7.0
FormatCurrency removes all "cosmetic" separators from the amount and changes decimal separators to the decimalSeparator. The function assumes that the decimal separator in the input is either ',' or '.'.
func GeneratePresetsFile ¶
func GeneratePresetsFile() error
GeneratePresetsFile writes an empty presets file to current user's home directory. If the file is already present, it returns an error.
Types ¶
type Params ¶
type Params struct {
// Path to the input CSV file.
Input string `json:"input"`
// Path to the output CSV file.
Output string `json:"output"`
// Overwrite output file if it exists.
Overwrite bool `json:"overwrite"`
// Collection of parameters describing the structure of input
// and the desired output CSV data.
Format Preset `json:"format"`
}
Params is a collection of parameters required for CSV file rewriting.
func (*Params) ApplyPreset ¶
ApplyPreset sets preset as the new value for Params.Format field.
type Preset ¶
type Preset struct {
// Input file encoding.
Encoding string `json:"encoding"`
// Pattern for output CSV file.
Pattern string `json:"pattern"`
// Character serving as comma in the input file.
InputComma string `json:"input_comma"`
// Indicates whether the header should be skipped.
SkipHeader bool `json:"skip_header"`
// This string will be inserted as the first row.
NewHeader string `json:"new_header"`
// Use CRLF instead of LF in the output file
UseCRLF bool `json:"crlf"`
// Decimal separator for currency.
CurrSep string `json:"curr_sep"`
}
Preset stores a combination of pattern and encoding. Presets can be written to the presets file to facilitate reuse.
func LoadPreset ¶
LoadPreset returns a Preset of the specified name from the presets file. If the Preset is not found, an error message is returned.