Easily extract and access columns from a csv file
Keep in mind that the indexes in the results have the same sequence as in the find_this
variable:
var clean = true
var find_this = []string { "Name", "Date", "Counter" }
var header_row = []string { "Counter", "Name", "Date" }
c, i, _ := csvtools.FindColumns(find_this, header_row, clean)
Result will be:
[ "Name", "Date", "Counter" ], [ 1, 2, 0 ]
Type: []string
A slice of columns to find. If empty, module will take all the columns available in the header_row
Type: []string
A row from csv file that you think is a header
Type: bool
Exclude non-existent columns from the results
// clean = false
[ "Name", "NonExistent", "Counter" ], [ 1, -1, 0 ]
// clean = true
[ "Name", "Counter" ], [ 1, 0 ]
Returns a column index by it's name. If column does not exists, returns -1
i := csvtools.IndexByName(column_name, mapped_list)
Type: string
Name of the column you are looking for
Type: map[string]int
A row from csv file that you consider a header