0

How can I get the individual values from the value variable below which gives me a string like this: 1001,10/01/2016,11/01/2016 and assign to each of my variable after the value?

var lines = loadedString.split('\n'); //split on newlines
	for (var i = 0; i < lines.length; i++)
	{
		var value = lines[i].split('\t');
		var id;
		var start;
		var end;
	}

2
  • 2
    Your code is looking reasonable, except that you're not splitting each line on the right character. Your separator appears to be a comma, not a tab. Commented Jan 11, 2017 at 0:04
  • 2
    if you're doing split('\t') that sounds like a tsv not a csv Commented Jan 11, 2017 at 0:05

1 Answer 1

1

Just like that:

var lines = loadedString.split('\n'); //split on newlines
    for (var i = 0; i < lines.length; i++)
    {
        var values = lines[i].split(',');
        var id = values[0];
        var start = values[1];;
        var end = values[2];;
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I will try your suggestion for thing tomorrow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.