I'm using tabletop in order to get data from google sheets in react js. I don't want to fetch data each time when the page is loaded instead I wish to get sheet's data by analyzing last modified time of the sheet and that of the time I last fetched data. is it possible in tabletop or by any means is this process possible? please help!!
AFAIK this is not possible with Tabletop or the Sheets API
You would need to use the:
Drive API
Specifically you would need to get the files resource which has, amongst many other fields:
{
"kind": "drive#file",
"id": string,
"name": string,
"mimeType": string,
"description": string,
"starred": boolean,
"trashed": boolean,
"viewedByMe": boolean,
"viewedByMeTime": datetime,
"createdTime": datetime,
"modifiedTime": datetime,
"modifiedByMeTime": datetime,
"modifiedByMe": boolean
}
To use this with your JavaScript, I would recommend first getting the quickstart working:
https://developers.google.com/drive/api/v3/quickstart/js
Then adapt it to your needs.
Related
I'm using the copy data activity in Azure Data Factory to copy data from an API to our data lake for alerting & reporting purposes. The API response is comprised of multiple complex nested JSON arrays with key-value pairs. The API is updated on a quarter-hourly basis and data is only held for 2 days before falling off the stack. The API adopts an oldest-to-newest record structure and so the newest addition to the array would be the final item in the array as opposed to the first.
My requirement is to copy only the most recent record from the API as opposed to the collection - so the 192th reading or item 191 of the array (with the array starting at 0.)
Due to the nature of the solution, there are times when the API isn't being updated as the sensors that collect and send over the data to the server may not be reachable.
The current solution is triggered every 15 minutes and tries a copy data activity of item 191, then 190, then 189 and so on. After 6 attempts it fails and so the record is missed.
current pipeline structure
I have used the mapping tab to specify the items in the array as follows (copy attempt 1 example):
$['meta']['params']['sensors'][*]['name']
$['meta']['sensorReadings'][*]['readings'][191]['dateTime']
$['meta']['sensorReadings'][*]['readings'][191]['value']
Instead of explicitly referencing the array number, I was wondering if it is possible to reference the last item of the array in the above code?
I understand we can use 0 for the first record however I don't understand how to reference the final item. I've tried the following using the 'last' function but am unsure of how to place it:
$['meta']['sensorReadings'][*]['readings'][last]['dateTime']
$['meta']['sensorReadings'][*]['readings']['last']['dateTime']
last['meta']['sensorReadings'][*]['readings']['dateTime']
$['meta']['sensorReadings'][*]['readings']last['dateTime']
Any help or advice on a better way to proceed would be greatly appreciated.
Can you call your API with a Web activity? If so, this pulls the API result into the data pipeline and then apply ADF functions like last to it.
A simple example calling the UK Gov Bank Holidays API:
This returns a resultset that looks like this:
{
"england-and-wales": {
"division": "england-and-wales",
"events": [
{
"title": "New Year’s Day",
"date": "2017-01-02",
"notes": "Substitute day",
"bunting": true
},
{
"title": "Good Friday",
"date": "2017-04-14",
"notes": "",
"bunting": false
},
{
"title": "Easter Monday",
"date": "2017-04-17",
"notes": "",
"bunting": true
},
... etc
You can now apply the last function to is, e.g. using a Set Variable activity:
#string(last(activity('Web1').output['england-and-wales'].events))
Which yields the last bank holiday of 2023:
{
"name": "varWorking",
"value": "{\"title\":\"Boxing Day\",\"date\":\"2023-12-26\",\"notes\":\"\",\"bunting\":true}"
}
Or
#string(last(activity('Web1').output['england-and-wales'].events).date)
I am POSTing valid JSON to a logic app and the request body is a simple set of name/value pairs in JSON format. I use parse JSON action to turn the JSON into a variable. (I am not sure if this is absolutely required, or if I can reference the http body directly without a JSON object).
[
{
"name": "fullname",
"value": "joe schmoe"
},
{
"name": "email",
"value": "joeschmoe#acme.com"
}
]
All I need to do (and this is driving me nuts) is create two variables, one containing the value of the email field and one containing the value of the fullname field.
As soon as I try to use the output value value, the logic app replaces my action with a For Each action, and then I try to to assign item().value[0] or item().value[1] to a variable without luck.
I have read dozens of examples online, but of course they all seem to be parsing JSON where there is largely unique elements in the name:value pairs.
While this is a bit of a newb question, I'm confused and need advice.
Thank you.
I used a parseJSON action to ensure I have a varaible containing the JSON array.
I then referenced the array value with (explained):
"from the body of the output from the Parse JSON action, refernce the first record in the set (fullname) and then the value of that record, the value 'joe schmoe'"
#{body('Parse_JSON')[0]['value']} (returns fullname)
Email is similar, just 2nd record in the collection:
#{body('Parse_JSON')[1]['value']} (returns email address)
We are a group of people writing a bachelor-project about storing sensor data into a noSQL-database, and we have chosen couchbase for this.
We want to store quite a few data in the same document, one document per day, per sensor, and we want to append new sensor data witch comes in every minute.
But unforunatly, we are not able to append new data into existing document without overwriting the existing data.
The structure for the documents is:
DocumentID: Sensor + date, ie: KitchenTemperature20180227
{
"topic": "Kitchen/Temp",
"type": "temperature",
"unit": "DegC"
"20180227130400": [
{
"data": "24"
}
],
..............
"20180227130500": [
{
"data": "25"
}
],
}
We are all new to couchbase and NoSql-databases, but eager to learn and understand how we the best way should implemet this.
We've tried upsert, insert and update commands, but they all overwrite the existing document or won't execute because the document already exists. As you can see, we have some top-level information, like topic, type, unit. The rest should be data coming in every minute and appended to the existing document.
Help on how to proceed would be very appriciated.
Best regards, Kenneth
In this case you can use the subdocument API. This allows you to modify portions of a document based on a "path". This image gives the idea for getting a subdocument.
You can mutate subdocuments as well. Look at the subdocument API documentation for Couchbase. There are also blog posts that go through examples in Java and Go on the Couchbase blog site.
I'm creating an AngularJS HTML app using Domino in the back-end. The communication is 100% rest-based via DDS
When I send date values they don't get converted to date items on the Domino document. The values are always stored as strings
I have tried various formats on the date string with no luck
Does anyone know is this is even possible with the Domino Data Services ?
I'm using Angulars $http service with the PATCH method to update changed values only
It is possible to store/ update a data in a document using Domino Data Services.
To get it to work you need to send the date as a string in ISO 8601 Extended format. That's the format that the toISOString() function returns in JavaScript for a Date object. On the form that you're trying to create or update, you'll need to have that field added as a Date/Time field. Adding the computewithform parameter to the request isn't required.
Here's a sample JSON object that, when send as a POST or PATCH request to DDS, will create/ update the LastVisit field as a DateTime field (assuming that field is on the form).
{
"FirstName":"Barney",
"LastName":"Bloomberg",
"LastVisit" : "2013-12-21T12:18:18Z"
}
The field name in the json string must be EXACTLY as on the form.
I had the similar problem where I had a field called 'TTL' on the form but my json generated by API using a class the field was named 'ttl'.
This resulted in a String as value for the date field, not a date.
This works :-)
I have extended the sample that I used in my presentation in the following way:
Added a field "WakeupTime" on the form. Set it to Date/Time, and select to display date and time. The sample output is 08-01-2016 16:11:42.
So reading the sample data using this url:
.../json.nsf/api/data/documents/unid/33735D0BCE799E01C1257CC3007A7221
I get something like this back:
{
"#href": "/demo/json.nsf/api/data/documents/unid/33735D0BCE799E01C1257CC3007A7221",
"#unid": "33735D0BCE799E01C1257CC3007A7221",
"#noteid": "902",
"#created": "2014-04-23T22:17:26Z",
"#modified": "2016-01-08T15:09:57Z",
"#authors": [
"Anonymous",
"CN=John Dalsgaard/O=D-D"
],
"#form": "Person",
"Unid": "33735D0BCE799E01C1257CC3007A7221",
"Key": "33735D0BCE799E01C1257CC3007A7221",
"Name": "Peter Hansen",
"Email": "ph#mail.dk",
"YearBorn": 1955,
"WakeupTime": "2016-08-01T05:33:10Z"
}
Important! - this gives me the exact format that I need to use for the WakeupTime field!
So if I then post a PATCH back with select fields:
{
"Email":"peter.hansen#mail.dk",
"YearBorn":1953,
"WakeupTime":"2016-01-08T05:33:40Z"
}
... and re-read the data then the fields are updated. And if I check in the Notes client I can see that the field is a date/time field :-)
Same happens if I create a new entry/document - the field is still the right type.
You have to be very aware of how you handle timezones though! The data are transferred as GMT :-)
I'm storing addresses data in Couchdb, and am looking for a way to get an array of just the values, instead of key: value for every record.
This is the current response:
{"total rows": 2438, "offset": 0, "rows":[
{"id": "ec5de6de2cf7bcac9a2a2a76de5738e4", "key": "user_298774", "value": {"city": "Milano", "address":"Corso Como, 42b"},
{"id": "a2a2a76de573ae4ec5de6de2cf7bcac9", "key": "user_276341", "value": {"city": "Vicenza", "address":"Via Quinto Sella, 118"}
... (etc).
]}
I only really need:
[{"city": "Milano", "address":"Corso Como, 42b"},
{"city": "Vicenza", "address":"Via Quinto Sella, 118"},
...]
I really need to minimize the usage of bandwidth that a JSON response consumes. I can't seem to find a way to transform the view into a simple array. Suggestions?
The response you are getting conforms to the Couch's REST based protocol. To reformat it two methods are provided: show functions and list functions. Basic idea is the same, but the first is suitable for retrieval documents and the list function is for you!
The list function runs the query inside the server and send the output arbitrary transformed with your JS code. API you will need is simple:
Fetch each record from the view with the getRow() function.
Export to the string (containing JSON) your JS object obj with toJSON(obj).
Send the output to the client with send(json).
If the map/reduce view URL with data is /mydb/_design/myapp/_view/mydocs-by-user and the list function name is mylist get the reformatted result to the client with the URL /mydb/_design/myapp/_list/mylist/mydocs-by-user.
Please refer to the list function documentation cited above and the chapter in the Guide for the longed tutorial.