I would like to upload data to a table in bigquery from gsheet, I mean I want to upload the data with code and not with add on, because it will be scheduled later on.
Is there any code example that I can use for that for both ways (append and truncate)?
I have a 2 columns data that I want to load.
The columns are:
name lastName
josh big
john troble
May be some code using the following function
BigQuery.Jobs.insert(resource, projectId)
Looker is great on top of BigQuery and provides a very easy interface for embedding query results in google sheets (as well as excel).
http://www.looker.com/docs/sharing-and-publishing/publishing-looks-with-public-urls
note, I work at (and on) Looker, but I also love BigQuery
Here is a tutorial showing how to use Apps Script within a Google Spreadsheet to: (1) run a query and extract the results and put them into the spreadsheet, and (2) run a load job to import a file from Google Cloud Storage:
https://developers.google.com/apps-script/advanced/bigquery
Since that tutorial was written, BigQuery now supports inserting table rows directly through the tabledata.insertAll method:
https://cloud.google.com/bigquery/docs/reference/v2/tabledata/insertAll
If you want to upload some rows from a Google Spreadsheet into a BigQuery table, it looks like you can use Apps Script to insert the rows directly to BigQuery.
Another approach that should work: you can use Apps Script to create a file in Google Cloud Storage, then you can use example #2 from the first link above to load the data. The Google Cloud Storage API is accessible through Apps Script, so this should be possible. Here's a post showing how one user accomplished this step: http://ctrlq.org/code/20074-upload-files-to-google-cloud-storage
You might want to check Google BigQuery API in Apps Script
https://developers.google.com/apps-script/advanced/bigquery
Upload Job is to be used after you get data from gsheet
BigQuery.Jobs.insert
Related
I'm creating a Discord Bot that will grab a specified chart from a Google Sheet and send the chart to the server. The sheet on hand will only ever have one chart at a time, so I've been able to find the correct chartId as follows:
sheets.spreadsheets.get({
spreadsheetId: 'MYSPREADSHEETID'
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
var id = res.data.sheets[0].charts[0].chartId;
});
However, I cannot find out how to export the corresponding chart as an image, or find a unique URL to the chart, or even recreate the chart using the existing data. I'm using discord.js and Google Sheets API v4.
At the moment of this post, unfortunately it is not possible to retrieve a chart as an image or get its specifc URL with Sheets API. Here I present three workarounds when we encounter the issue of trying to retrieve the image of a chart in a spreadsheet.
Workaround 1
If your main intention is to get the chart data to then use it somewhere else or create a data Blob with it for other Google Applications, you can use the API method GET requesting only the desired fields (in our case, the chart objects) as shown in this example of the documentation.
Workaround 2
If what you need is to easily access this chart image with a simple link, you could publish your chart following these steps shown in the documentation. This can generate either a link or an embed for your website that you can easily share and use.
Workaround 3
You can use Apps Script to create a Web App and using the API method in the first workaround generate a Blob from the chart object and use it to be inserted as an image either in another sheet or in a HTML page. In this Stack Overflow answer you can see an exmple of the implementation of this workaround.
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
I have one excel file which will be filled by many users. How can I pull data from cell B2 for example, to be automatically placed somewhere in HTML page using javascript?
Try threating the excel as .csv like in this tutorial or this youtube video instead of calling a local file call the excel by url
CSV libraries are mostly compatible.
Hope that will be helpful.
You need to place that excel sheet in a database first(SQL specially as it's a relational database)and from there you can call that row using Http method easily via JS.
I am needing some JS that can Vlookup a piece of information from an XLSX or CSV file.
My example is this:
I have a spreadsheet containing balances of accounts.
When a person logs into their account, the variable 'ACCTNO' is currently set as their account number (example - 95785879).
I would like this to lookup the information from my spreadsheet which is found at C:\Users\Username\Desktop\AccountBalances.xlsx and return the balance of the account as shown below. In this example. the returned number should be £4.19.
Screenshot of Excel File
Javascript cannot access the local filesystem. You should consider putting this information in JSON format and declaring it in your JS code, or look at a server-side solution such as a database.
In this problem i need a curl script where i can check all my records by email id's of customer,So for this stuff i have text file source from where i can see customer email id's and then implement in script
Need more details on exactly what you are trying to achieve.
The closest that you can achieve this is thru the RESTLET API of Netsuite. Pre-requisite is to know how REST works and suitescript API.
I'm trying to load the ratings, used in this Google website, in my own page.
http://www.google.com/maps/place?source=uds&q=restaurants&cid=10470472694367837337
I'd like to show the ratings on my own website, so just loading the ratings-DIV would do the trick.
Any ideas?
You could use PHP (or another backend language) to crawl that page, extracting the div, then pass it to the website.
However, seeing how the ratings come from google, I'd suggest you take a look if there isn't some google API you can use to get the ratings. I don't know what API you can use from mind but this should help you out with that.
http://code.google.com/intl/nl-NL/more/table/
Get the page and parse it.
For PHP you could use http://www.phpclasses.org/package/3086-PHP-Parse-and-extract-information-from-HTML-using-SQL.html to parse it in a SQL style.
You shouls use the places api google provide. Its a webservice that returns information on places and locations. You will need a google account and to setup a api key which you can do here
You can then call this api from client or server side code. The place details results of the place Details api call returns a rating.
You should not just extract html content from another sites webpage!
You can use PHP Simple HTML DOM Parser http://simplehtmldom.sourceforge.net/
$html = file_get_html('http://www.google.com/maps/place?source=uds&q=restaurants&cid=10470472694367837337');
foreach ($html -> find('div.rsw-stars') as $element)
print count($element -> find('.rsw-starred')) . '<br>';