Skip to content

Commit 1e79cfe

Browse files
author
utkarsh
committed
added date formatting
1 parent 576a79f commit 1e79cfe

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

functions/gcs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const BigQuery = require('@google-cloud/bigquery');
2626
const projectId = 'secure-unison-207809';
2727
const datasetId = 'healthdata';
2828
const _ = require('underscore');
29-
29+
const moment = require('moment');
3030
function getFileStream(file) {
3131
if (!file.bucket) {
3232
throw new Error('Bucket not provided. Make sure you have a "bucket" property in your request');
@@ -101,7 +101,7 @@ function insertRowsAsStream(tableId, rows, cb) {
101101
});
102102
let transformedRows = rows.map(row => {
103103
row.Height = row.Height.replace(',', '.');
104-
row.Date = row.Date.replace(/[/]/g, '-');
104+
row.Date = moment(row.Date, "MM/DD/YYYY").format("YYYY-MM-DD")
105105
return row;
106106
})
107107
// Inserts data into a table

functions/gcs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@google-cloud/bigquery": "^1.3.0",
2121
"@google-cloud/storage": "1.6.0",
2222
"csv-parse": "^2.5.0",
23+
"moment": "^2.22.2",
2324
"request": "2.83.0",
2425
"underscore": "^1.9.1"
2526
},

0 commit comments

Comments
 (0)