Documentation ¶
Index ¶
- Constants
- func CSVFilesFromEmbeddedFS(embeddedFS embed.FS, directory string) (csvFilesInDirectory []string)
- func CSVOutputFileName(directory, inputFile string) string
- func FileNameWithUNIXTimestamp(file string) string
- func OpenFile(file string, osFlag int) (*os.File, error)
- func ReadCSV(fs embed.FS, csvFile string, csvRowsChannel chan []string, wg *sync.WaitGroup, ...)
- func ReadHeader(fs embed.FS, csvFile string, nbHeaderRows int) (header [][]string)
- func WriteToCSV(outputFile string, osFlags int, csvOutputChannel chan []string, ...)
Constants ¶
Re-export the package `os`'s constants so that packages that depend on csv_helper's `OpenFile` func don't need to depend on package `os` as well
Variables ¶
This section is empty.
Functions ¶
func CSVFilesFromEmbeddedFS ¶
CSVFilesFromEmbeddedFS returns all csv files in a directory from an embedded FS
func CSVOutputFileName ¶
CSVOutputFileName returns name of csv file suffixed with the current unix timestamp and with the directory `directory` prefixed to its path Example: inputFile: "./data/something.csv" output: "./data/`directory`/something_`current unix timestamp`.csv"
func FileNameWithUNIXTimestamp ¶
returns the file name concatenated with the current unix timestamp before the file extension Example: file: "something.csv" output: "something_`current unix timestamp`.csv"
func OpenFile ¶
OpenFile creates the file `file` and all the directories specified in `file`'s path if they don't exist. The available options for `osFlag` are `APPEND` (which will open the specified file without overwriting it) and `CREATE` (which will overwrite the specified file if it exists)
func ReadCSV ¶
func ReadCSV(fs embed.FS, csvFile string, csvRowsChannel chan []string, wg *sync.WaitGroup, nbSkipHeader int)
ReadCSV reads a csv file into the channel `csvRowsChannel`.
func ReadHeader ¶
ReadHeader returns the specified number of rows from the start of a csv file
func WriteToCSV ¶
WriteToCSV writes to the specified output file with the contents from the channel `csvOutputChannel`. Writing is stopped when `csvOutputChannel` is closed. Please read the doc of `OpenFile` to understand the available options for the `osFlags` argument.
Types ¶
This section is empty.