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

Reading From CSV files into quote object causes error #12

Open
FarhanSajid1 opened this issue Dec 13, 2019 · 0 comments
Open

Reading From CSV files into quote object causes error #12

FarhanSajid1 opened this issue Dec 13, 2019 · 0 comments

Comments

@FarhanSajid1
Copy link

When reading a csv file into a quote object there is a slight error which needs to be checked before reading the file.

NewQuoteFromCSV(symbol, csv string) (Quote, error) {

	tmp := strings.Split(csv, "\n")
	numrows := len(tmp)
	q := NewQuote(symbol, numrows-1)

	for row, bar := 1, 0; row < numrows; row, bar = row+1, bar+1 {
		line := strings.Split(tmp[row], ",") # we need to add in a conditional check as such
                if len(line) != 6 {
			break
		}

The reason being is that the way that the "records" are being written a "\n" is automatically appended at the end, this simple check worked and helped me avoid the annoying out of bounds error.

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

No branches or pull requests

1 participant