Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mapping struct fields by header index. #72

Open
ArtuoS opened this issue Jan 23, 2025 · 0 comments
Open

Add support for mapping struct fields by header index. #72

ArtuoS opened this issue Jan 23, 2025 · 0 comments

Comments

@ArtuoS
Copy link

ArtuoS commented Jan 23, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants