csvutil icon indicating copy to clipboard operation
csvutil copied to clipboard

Add support for mapping struct fields by header index.

Open ArtuoS opened this issue 1 year ago • 0 comments

In scenarios where header names are randomly generated from an external source, it would be beneficial to unmarshal the CSV into a struct using the header index. Another scenario is when people use cleaning tools in the project (e.g., field alignment), the tool can reorganize the structs, making it difficult to maintain an exact order.

Struct example:

type User struct {
	Name string `index:"0"`
	Age  int    `index:"1"`
}

CSV example:

ax9KEfo,lo20dUta
James,22
Victoria,31

ArtuoS avatar Jan 23 '25 19:01 ArtuoS