From f9fe6103da50a4a2cd167c6005414c323c011825 Mon Sep 17 00:00:00 2001 From: AswinT22 <42780141+AswinT22@users.noreply.github.com> Date: Mon, 27 Apr 2020 07:52:17 +0530 Subject: [PATCH] Delete csvUtils.js --- utils/csvUtils.js | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 utils/csvUtils.js diff --git a/utils/csvUtils.js b/utils/csvUtils.js deleted file mode 100644 index 61271ba..0000000 --- a/utils/csvUtils.js +++ /dev/null @@ -1,39 +0,0 @@ -const fs = require('fs'); -const csv = require('csv-parser'); -const path = require('path'); -const csvWriter = require('csv-write-stream'); -const patternUtils = require(path.join(__dirname,"candleStickPatternUtils")); -const stringUtils = require(path.join(__dirname,"stringUtils")); -const chartUtils = require(path.join(__dirname,"chartUtils")); - -module.exports.filterHammerAndWrite = function (inputFilePath, outputFilePath, render) { - // using streams to handle large datasets - var writer = csvWriter(); - writer.pipe(fs.createWriteStream(outputFilePath, {flags: 'a'})); - - var map = {};// handle duplicates - console.log("Identifying hammer candlestick pattern....."); - fs.createReadStream(inputFilePath) - .on('error', (err) => { - console.log(err); - }) - .pipe(csv()) - .on('data', (row) => { - var hash = stringUtils.stringToHash(row.Date); - if (hash in map) { - // Duplicates - return - } - map[hash] = 1 - if(patternUtils.isHammer(row)) { - writer.write(row); - } - }) - .on('end', () => { - writer.end(); - console.log("Find the filtered csv at", outputFilePath); - if (render) { - chartUtils.renderChart(outputFilePath, "filtered-hammer-chart"); - } - }); -}