Reputation: 1982
What Im trying to do: 1. Read the file 2. Split the read file.
Here is a sample input file -
#This is a comment
Line one of first block,
Line two of first block,
Line three of first block.
Line one of second block.
Line two of second block
line three of second block.
Line one of third block.
Each block is separated by newlines ( no control over whether they would be windows/unix). How to go about using getting each block read separately using nodejs?
Upvotes: 0
Views: 343
Reputation: 7047
I'd suggest you to use split() function.
var blocks = str.split([separator],[limit]);
After this you may try to iterate the array like
blocks.each(function(err, block) {
console.log(block);
});
However, you should check, what to specify as separator - Windows or UNIX (CRLF or just LF).
Upvotes: 1