Esempio n. 1
0
basicCSV.readCSV(csvFile, {dropHeader: true}, function (error, rows) {
    underlying = rows[2][0];
    var rawData = rows.slice(6,rows.length);
    var dateIndicies = [];
    for(var i = 0; i < rawData.length; i++){
        var row = rawData[i];
        if(isCBOEdate(row[0])){
            var date = CBOEdate(row[0]);
            dateObj = {"date":date.format("MM/DD/YY"),"index":i};
            dateIndicies.push(dateObj);
        };
    };
    for(var i = 0; i < dateIndicies.length; i++){
        var thisIndex = dateIndicies[i],
        nextIndex = dateIndicies[i+1]?dateIndicies[i+1]:rawData.length,
        rawSlice = rawData.slice(thisIndex.index,nextIndex.index);
        data[thisIndex.date] = [];
        for(var j = 0; j < rawSlice.length; j++){
            var row = rawSlice[j];
            if(isNumber(row[10]) && row[10]>0){
                //Calls
                if(isNumber(row[2]) && row[2]>0){
                    var optObj = {};
                    optObj.call = 1;
                    optObj.strike = parseFloat(row[10]);
                    optObj.price = parseFloat(row[2]);
                    data[thisIndex.date].push(optObj);
                };
                //Puts
                if(isNumber(row[15]) && row[15]>0){
                    var optObj = {};
                    optObj.call = 0;
                    optObj.strike = parseFloat(row[10]);
                    optObj.price = parseFloat(row[15]);
                    data[thisIndex.date].push(optObj);
                };
            };
        };
    };
    analyze();
});
Esempio n. 2
0
var basicCsv = require('basic-csv');

basicCsv.readCSV(process.argv[2], (err, rows) => console.log(rows));
"use strict";

var csv = require("basic-csv")
var fs = require("fs")

csv.readCSV(__dirname + "/../data/alphabets.csv", function (error, rows) {
  var alphabets = rows.map(function(row){
    var alphabet = {
      name: row[0].trim(),
      language: row[1].trim(),
      description: row[2].trim(),
      year: row[3].trim()
    }

    if (!alphabet.description) delete(alphabet.description)
    if (!alphabet.year) delete(alphabet.year)

    alphabet.mapping = {}

    row[4].trim().split(" ").forEach(function(word) {
      alphabet.mapping[word.slice(0,1)] = word
    })

    return alphabet
  })

  fs.writeFileSync(__dirname + "/../data/alphabets.json", JSON.stringify(alphabets, null, 2))

})
Esempio n. 4
0
// get your requirements in order.
var u = require('underscore'),
basicCSV = require('basic-csv');
//u.nst = require('underscore.nest');
var csvFile = "./domestic-revenue-finance-and-expenditure.csv"


basicCSV.readCSV(csvFile, {dropHeader: true}, function (error, rows) {
    console.log(rows.length)
});