Public
Edited
Feb 8, 2024
Insert cell
Insert cell
Insert cell
Insert cell
data = [{"id":"1","first_name":"John","last_name":"Doe","dob":"1968-01-22","address":"123 First Avenue, Seattle WA 11111"},{"id":"2","first_name":"Jane","last_name":"Doe","dob":"1980-10-16","address":{"status":"current","address":"789 Any Avenue","city":"New York","state":"NY","zip":"33333","numberOfYears":"2"}},
{"id":"3","first_name":"Bob","last_name":"Doe","dob":"1982-01-10","address":[{"status":"current","address":"789 Any Avenue","city":"New York","state":"NY","zip":"33333","numberOfYears":"2"}, "321 Main Street Hoboken NJ 44444"]}]
Insert cell
Insert cell
Insert cell
//const { Storage } = require("@google-cloud/storage");
/**
* Responds to any HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
//const functions = require('@google-cloud/functions-framework');
// const Storage = require('@google-cloud/storage');
// const bucket_name = 'pgs-bucket'
// const storage = new Storage();
// exports.helloWorld = async function(req, res) {
// console.log("hello! ")
// }
// async function getData() {
// let response = await fetch('https://www.pgscatalog.org/rest/trait/all')
// const data = await response.json();
// // save data to storage bucket
// const file = storage.bucket(bucket_name).file("file14.json");
// const contents = JSON.stringify(data);
// file.save(contents);
// //stream HTTP requests to BigQuery
// //console.log(data);
// return data
// }
// let data = getData()
// // Imports the Google Cloud client library
// const {BigQuery} = require('@google-cloud/bigquery');
// /**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = "your-project-id";
// const datasetId = "my_dataset";
// const tableId = "my_table";
// const rows = [{name: "Tom", age: 30}, {name: "Jane", age: 32}];
// Creates a client
const bigquery = new BigQuery(
{ projectId: projectId"}
);

// Inserts data into a table
async function queryExternalGCSPerm() {
let dt = await data
const rows = dt.results.map(({id,label}) => {return {id,label}; })//[{name: "Tom", age: 30}, {name: "Jane", age: 32}];
console.log("data.results",rows)

await bigquery
.dataset("pgsFilesLorena")
.table("pgs1")
.insert(rows);
console.log(`Inserted ${rows.length} rows`);
}
queryExternalGCSPerm()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more