Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added example.js

  • Loading branch information...
commit 92f6fde50102afb58500c3251c147c20aee7ff22 1 parent bf8a6b3
Andrew Maurer authored

Showing 2 changed files with 29 additions and 1 deletion. Show diff stats Hide diff stats

  1. +26 0 example.js
  2. +3 1 log-massage.js
26 example.js
... ... @@ -0,0 +1,26 @@
  1 +var fs = require("fs");
  2 +var LogMassage = require("./log-massage.js");
  3 +
  4 +var logFilePath = "mylog.log";
  5 +
  6 +
  7 +fs.readFile(logFilePath, function(e, data){
  8 +
  9 + var count = 0;
  10 + var lm = new LogMassage(data)
  11 + .toDate(2, 3)
  12 + .removeRowCells(1, 4)
  13 + .filterBetween(
  14 + new Date("12/03/12"),
  15 + new Date("12/04/12"),
  16 + 2
  17 + )
  18 + .eachRow(function(rowIndex, row){
  19 + count++;
  20 + return true;
  21 + });
  22 +
  23 + console.log(lm);
  24 + console.log(count);
  25 +
  26 +});
4 log-massage.js
@@ -35,6 +35,8 @@ LogMassage.prototype.toArrays = function(stringData){
35 35 var logResults = [];
36 36 var rows = stringData.toString().split(this.rowDelimiter);
37 37 var cells = [];
  38 + var replaceQuotes = /"/g;
  39 + var replaceCarriageReturns = /\r/g;
38 40 for (i = 1, len = rows.length; i<len; i++) {
39 41 x = rows[i];
40 42 if(x === "" || x.length === 0) continue;
@@ -42,7 +44,7 @@ LogMassage.prototype.toArrays = function(stringData){
42 44 tmp = [];
43 45 for (ii = 0, lenn = cells.length; ii<lenn; ii++) {
44 46 tmp.push(
45   - cells[ii].replace(/"/g, "").replace(/\r/g, "")
  47 + cells[ii].replace(replaceQuotes, "").replace(replaceCarriageReturns, "")
46 48 );
47 49 };
48 50 logResults.push(tmp);

0 comments on commit 92f6fde

Please sign in to comment.
Something went wrong with that request. Please try again.