Synchronous processing of a csv file using fast-csv
<p>I am trying to process a csv file using fast-csv and here is my code.</p>

<pre><code>    var stream = fs.createReadStream("sample.csv");
    csv.fromStream(stream, {headers : true})
    .on("data", function(data) {
            console.log('here');
            module.exports.saveData(data, callback)
        })
    .on("end", function(){
        console.log('end of saving file');
    });

    module.exports.saveData = function(data) {
    console.log('inside saving')
    }
</code></pre>

<p>The problem that I am facing is the process is not synchronous. 
The output that I am seeing is something like</p>

<p>here<br>
here<br>
inside saving<br>
inside saving  </p>

<p>But, What I want is </p>

<p>here<br>
inside saving<br>
here<br>
inside saving  </p>

<p>I am assuming we need to use async.series or async.eachSeries but not exactly sure how to use that here. Any inputs are greatly appreciated</p>

<p>Thanks in Advance!</p>