Skip to content

ToString for CSV Parser results #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kishorenagarajan
Copy link

The ParseToString() function added to the parser file allows a user to input their parsed structs and get back a string version of its contents. The function prints the values of the structs regardless of the var types for the fields within each struct.

Given array of structs from the parsed csv, prints out the contents of the file parsing in a nice string format.
The input of the function can take in any type of structs with any number of fields within the struct.
*/
func ParseToString(arr []interface{}) string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing!
I like the idea of having a ParseToString helper. Maybe we could just put this function in a new .go file? Maybe a file with the name helpers.go.
Also, could you add a unit test or two? It would be nice to have everything tested.

for i, s := range res {
translate[i] = s
}
resultString := parseToString(translate)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be csvparser.ParseToString(translate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants