0

I am new to GCP requesting some help to solve my issue.

I am creating CSV file, json file and java script file and uploading into GCP bucket. Creating the 'Text files on cloud storage to big query' Dataflow template to populate the data into bigquery.

Need some help in converting the date format from DD-MM-YYYY to YYYY-MM-DD in big query by using 'text files on cloud storage to big query ' Dataflow template in GCP.

  • 1
    The explanation is quite clear in the documentation. What have you tried? Where are you stuck? Do you have line samples to understand the full content of a row, and the field that you want to convert?? – guillaume blaquiere Jun 12 '21 at 18:09
  • Thanks for your help - i have shared the data via share point link and i have marked the date in the image that i want to change from DD-MM-YYYY to YYYY-MM-DD. i am new to gcp and sorry for poor explanation. https://1drv.ms/u/s!ArQzbfwq4Gd-gixwyw07IHCzYhx8?e=xW3Kbp – Ravi Teja Jun 13 '21 at 04:05

1 Answers1

1

In the JS file, you should have something like that

function transform(line) {
var values = line.split(',');

var obj = new Object();
obj.VAERS_ID = values[0];
obj.RECVDATE = values[1];
obj.STATE = values[2];
obj.AGE_YRS = values[3];
obj.CAGE_YR = values[4];
......
var jsonString = JSON.stringify(obj);

return jsonString;
}

You want to change the format of the second like, the RECVDATE. So, do it like that

function transform(line) {
var values = line.split(',');

var splitted = values[1].split("-")

var obj = new Object();
obj.VAERS_ID = values[0];
obj.RECVDATE = splitted[2] + "-" + splitted[1] + "-" + splitted[0];
obj.STATE = values[2];
obj.AGE_YRS = values[3];
obj.CAGE_YR = values[4];
......
var jsonString = JSON.stringify(obj);

return jsonString;
}

Should be enough. Let me know.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76