-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d70e494
commit 1329301
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Square -> Integromat -> Google Sheets -> CSV collation of order picklist | ||
|
||
const fs = require('fs'); | ||
const readline = require('readline'); | ||
|
||
async function processLineByLine() { | ||
const fileStream = fs.createReadStream('/Users/chrisnewman/desktop/orders.txt'); | ||
|
||
const rl = readline.createInterface({ | ||
input: fileStream, | ||
crlfDelay: Infinity | ||
}); | ||
|
||
var map = {}; | ||
|
||
for await (const line of rl) { | ||
if(line.trim() !== "\""){ | ||
var tokens = line.split(":"); | ||
var key = tokens[0].trim(); | ||
var value = parseInt(tokens[1].trim()); | ||
|
||
if(key in map){ | ||
map[key] = map[key]+value; | ||
} | ||
else{ | ||
map[key] = value; | ||
} | ||
} | ||
|
||
} | ||
|
||
console.log(map); | ||
} | ||
|
||
processLineByLine(); | ||
|