Created
June 17, 2016 01:28
-
-
Save dsomel21/429609aa92b3aee08da3af1770f1ad40 to your computer and use it in GitHub Desktop.
quick parse of csv
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
var dilraj = { | |
date: '', | |
time:[], | |
bg:[], | |
bolus:[], | |
carbs:[], | |
total:[] | |
}; | |
var stream = fs.createReadStream(file); | |
csv.fromStream(stream, {headers : true }) | |
.on("data", function(data){ | |
// console.log(data); | |
// if (data['Daily Insulin Total (U)'] > 0) { | |
// dilraj.date = data['Date']; | |
// } | |
// dilraj.time.push(data['Time']); | |
// dilraj.bg.push(data['BG Reading (mmol/L)']); | |
// dilraj.bolus.push(data['BWZ Estimate (U)']); | |
// dilraj.carbs.push(data['BWZ Carb Input (grams)']); | |
// dilraj.total.push(data['Daily Insulin Total (U)']); | |
if (data['Daily Insulin Total (U)'] > 0) { | |
console.log('-------------------------------------------------------------------------------------------------------------------------'); | |
} | |
// Logbook.create({ | |
// date: data['Date'], | |
// time: data['Time'], | |
// bg_reading:data['BG Reading (mmol/L)'] | |
// }) | |
// if (data['BWZ Insulin Sensitivity (mmol/L)'] > 0){ | |
console.log('Index:', data['Index'], 'Date:', data['Date'], | |
'Time:', | |
data['Time'], 'BG Reading (mmol/L):', | |
data['BG Reading (mmol/L)'], 'BWZ Estimate (U):', | |
data['BWZ Estimate (U)'], 'BWZ Carb Input (grams)', | |
data['BWZ Carb Input (grams)'], 'Daily Insulin Total (U):', | |
'BWZ Insulin Sensitivity (mmol/L):', data['BWZ Insulin Sensitivity (mmol/L)']); | |
// data['Daily Insulin Total (U)']); | |
// } | |
}) | |
.on("end", function(){ | |
console.log("[Completed]"); | |
console.log(dilraj); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment