Bulk Channel Report has Elements with no Video ID - youtube

I have a few different channels where I am using bulk channel reports, and in the channel_basic_1a and 2a reports, I am noticing some elements that are getting returned with statistics, but no video_id to associate them with.
Has anybody else encountered this behavior? I have noticed this across several days, and it's a relatively small part of my total data set, but noticeable. This occurred three times on this one particular day, one in country US, one in ZZ and one in JO.
Here's an example json element:
{
"date": "20150731",
"card_teaser_click_rate": "0",
"subscribed_status": "subscribed",
"card_clicks": "0",
"annotation_closable_impressions": "0",
"shares": "0",
"annotation_closes": "0",
"card_impressions": "0",
"videos_removed_from_playlists": "0",
"annotation_impressions": "0",
"annotation_clickable_impressions": "0",
"annotation_click_through_rate": "0",
"views": "0",
"likes": "0",
"annotation_clicks": "0",
"comments": "0",
"average_view_duration_seconds": "0",
"live_or_on_demand": "on_demand",
"card_teaser_clicks": "0",
"videos_added_to_playlists": "0",
"card_click_rate": "0",
"dislikes": "0",
"subscribers_lost": "0",
"watch_time_minutes": "0",
"annotation_close_rate": "0",
"card_teaser_impressions": "0",
"country_code": "US",
"average_view_duration_percentage": "0",
"channel_id": "*******",
"subscribers_gained": "10",
"video_id": ""
},

Related

create a data model clsss to json in swift

This is the json I got from server I tried to create a data model for this json but didn't get in to success because of nested arrays. can anyone please help in creating data model for this jsonfile in swift. if you need I can provide the the data model I created for this json but that is not working
{
"result": [
{
"loo_id": null,
"loo_name": null,
"loo_address": null,
"loo_image": null,
"price": null,
"loo_location": null,
"type": null,
"category": [
{
"category_id": "1",
"category_name": "Hotel",
"cat_enable_image": "****images/category/hotel_clr.png",
"cat_disable_image": "****images/category/hotel_gry.png",
"status": "0"
},
{
"category_id": "5",
"category_name": "Shopping Mall",
"cat_enable_image": "****images/category/shopping_mall_clr.png",
"cat_disable_image": "****images/category/shopping_mall_gry.png",
"status": "0"
}
],
"days": null,
"timings": null,
"facilities": [
{
"facility_category_id": "1",
"facility_category_name": "Male",
"facility_category_enable_image": "****images/facility_category/male_clr.png",
"facility_category_disable_image": "****images/facility_category/male_gry.png",
"status": "0",
"facility": [
{
"facility_id": "1",
"facility_name": "Toiletten",
"enable_image": "****images/facilities/toilet_color.png",
"disable_image": "****images/facilities/toilet_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "2",
"facility_name": "Lavatory",
"enable_image": "****images/facilities/lavatory_color.png",
"disable_image": "****images/facilities/lavatory_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "3",
"facility_name": "Urinals",
"enable_image": "****images/facilities/urinals_color.png",
"disable_image": "****images/facilities/urinals_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "4",
"facility_name": "Shower",
"enable_image": "****images/facilities/shower_color.png",
"disable_image": "****images/facilities/shower_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "5",
"facility_name": "Standing Toilet",
"enable_image": "****images/facilities/standing_toilet_color.png",
"disable_image": "****images/facilities/standing_toilet_grey.png",
"count": "0",
"status": "0"
}
]
},
{
"facility_category_id": "4",
"facility_category_name": "Wheelchair",
"facility_category_enable_image": "****images/facility_category/1771138800.png",
"facility_category_disable_image": "****images/facility_category/1790222751.png",
"status": "0",
"facility": [
{
"facility_id": "12",
"facility_name": "Toiletten",
"enable_image": "****images/facilities/toilet_color.png",
"disable_image": "****images/facilities/toilet_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "13",
"facility_name": "Lavatory",
"enable_image": "****images/facilities/lavatory_color.png",
"disable_image": "****images/facilities/lavatory_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "14",
"facility_name": "Shower",
"enable_image": "****images/facilities/shower_color.png",
"disable_image": "****images/facilities/shower_grey.png",
"count": "0",
"status": "0"
}
]
}
],
"accessbility": [
{
"accessbility_id": "1",
"accessbility_name": "Wheelchair",
"accessbility_enable_image": "****images/accessbility/wheelchair_clr.png",
"accessbility_disable_image": "****images/accessbility/wheelchair_gry.png",
"status": "0"
},
{
"accessbility_id": "2",
"accessbility_name": "Car Access",
"accessbility_enable_image": "****images/accessbility/car_access_clr.png",
"accessbility_disable_image": "****images/accessbility/car_access_gry.png",
"status": "0"
}
],
"terms_conditions": null
}
]
}

Microsoft Graph POST New Row to Excel Table

I am trying to post a new row of data to an Excel table. I am sending a POST request to the Table / Rows. A new row is being added but with empty values. This happens both when I POST from code and also if I POST from the Microsoft Graph Explorer.
The POST statement I am using is:
POST /v1.0/drives/{driveid}/items/{itemid}/workbook/tables/{tableid}/rows
content-type: Application/Json
authorization: Bearer {access-token}
{
"value": [{
"values": [
["44444 : 22/08/2017 12:14:46",
"44444",
"22/08/2017 12:14:46",
"New Name",
"Status",
"01/10/2017 12:14:46",
"563",
"Filename"
]
],
"index": null
}]
}
I get a successful response message but with empty field values and the table has a blank row added.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives({driveid)/items(itemid)/workbook/tables({tableid})/rows/$entity",
"#odata.id": "/drives({driveid})/items({itemid})/workbook/tables({tableid})/rows(null)",
"index": 2,
"values": [
[
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
]
]
}
How do I get the POST to include the values into the new row?
After more experimenting I have found what I have done wrong. My table has more columns in it than I was posting to. You need to post to all columns. I needed to add an additional two blank fields in this case. When the correct number of values was included the post works.
The JSON needs to be formatted like this as well as needing to have a value for each column in the table.
{ "values": [ [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29" ] ] }

How to sort multidimensional array in swift?

I need your help. I did an array, and when I launch my application on different devices or simulator, this array sorted into different types, but I need the same order on each device. How to do that?
var settings = [String: [ [String: String] ]]()
settings = [ "cards":[ ], "groups":[ ] ]
...
for card in db.prepare(table.order(orderN.asc)) {
settings["cards"]?.append(["id":String(card[id]), "group_id":String(card[group_id]), "service":card[service], "bgcolor":card[bgcolor], "logoimg":card[logoimg]!, "balance_desc":card[balance_desc], "balance":"0.0", "balance_id":String(card[balance_id]), "uniqueID":card[uniqueID], "balance_currency":String(card[balance_currency]), "orderN":String(card[orderN])])
}
...
for group in db.prepare(table.order(orderN.asc)) {
settings["groups"]?.append(["name":group[name]!,"id":String(group[id]),"orderN":String(group[orderN])])
}
...
For example,
On the first device
print(settings) // ["cards": [["orderN": "0", "bgcolor": "0.0, 0.0, 0.0, 1.0", "balance": "0.0", "logoimg": "example.com/images/img.png", "uniqueID": "00a2413f74f4a3f186e439a67057de67", "group_id": "2", "id": "1", "service": "servicename", "balance_desc": "Description", "balance_id": "1", "balance_currency": "1"]], "groups": [["orderN": "0", "name": "GroupName", "id": "2"]]]
On the second device
print(settings) // ["cards": [["orderN": "0", "uniqueID": "00a2413f74f4a3f186e439a67057de67", "service": "servicename", "id": "1", "bgcolor": "0.0, 0.0, 0.0, 1.0", "balance_currency": "1", "balance": "0.0", "group_id": "2", "logoimg": "example.com/images/img.png", "balance_id": "1", "balance_desc": "Description"]], "groups": [["id": "2", "orderN": "0", "name": "GroupName"]]]
Thank you for you attention.
That's because settings is not an Array, it's Dictionary. Order of key-value pairs in dictionary is not defined.
If you need some particular order, you should reimplement settings, probably make them separate struct or class, because you'll have a hard time working with nested dictionaries.

How to combine hash with an array and display result as json

I'm trying to display a json after different SQL queries. Some of the SQL queries return one value but I got an array of results from one of the queries. You can see the example of the json that I want to show below.
{
"id": "4",
"potential": "23",
"conversion": "45",
"new": "34",
"repeat": "22",
"average": "14",
"traffic": [
{
"time": "9",
"new": "2",
"repeat": "1"
},
{
"time": "10",
"new": "6",
"repeat": "9"
}
]
}
I can display separately hash and array as json, however I can't combine them.
{
"id": "4",
"potential": "23",
"conversion": "45",
"new": "34",
"repeat": "22",
"average": "14"
}
AND
[
{
"time": 5,
"new": 0,
"repeat": 80
},
{
"time": 6,
"new": 1,
"repeat": 80
}
]
Any suggestions? Thank you
Traverse the response you get and add the data into a Hash. Here is a ruby-doc for it. If you need a bit idea of how to use hash see below code.
x = {"id" => "4", "potential" => "23","conversion"=> "45","new"=> "34","repeat"=> "22","average"=> "14"}
x["traffic"] =[{"time"=>5,"new"=>0,"repeat"=>80},{"time"=>6,"new"=>1,"repeat"=>80}]
You would have to use your logic to build the hash. I just wrote something for you. Also you can then return the hash by render :json => x.

Ruby Mechanize screen scraping help

I am trying to scrape a row in a table with a date. I want to scrape only the third row that have the date today.
This is my mechanize code. I am trying to select the colum row witch have the date today and its and its columns:
agent.page.search("//td").map(&:text).map(&:strip)
Output:
"11-02-2011", "1", "1", "1", "1", "0", "0,00 DKK", "0,00", "0,00 DKK",
"12-02-2011", "5", "5", "1", "4", "0", "0,00 DKK", "0,00", "0,00 DKK",
"14-02-2011", "1", "3", "1", "1", "0", "0,00 DKK", ",00", "0,00 DKK",
"7", "9", "3", "6", "0", "0,00 DKK", "0,00", "0,00 DKK
"
I want to only scrape the third row that is the date today.
Rather than loop over the <td> tags using '//td', search for the <tr> tags, grab only the third one, then loop over '//td'.
Mechanize uses Nokogiri internally, so here's how to do it in Nokogiri-ese:
html = <<EOT
<table>
<tr><td>11-02-2011</td><td>1</td><td>1</td><td>1</td><td>1</td><td>0</td><td>0,00 DKK</td><td>0,00</td><td>0,00 DKK</td></tr>
<tr><td>12-02-2011</td><td>5</td><td>5</td><td>1</td><td>4</td><td>0</td><td>0,00 DKK</td><td>0,00</td><td>0,00 DKK</td></tr>
<tr><td>14-02-2011</td><td>1</td><td>3</td><td>1</td><td>1</td><td>0</td><td>0,00 DKK</td><td>,00</td><td>0,00 DKK</td></tr>
</table>
EOT
require 'nokogiri'
require 'pp'
doc = Nokogiri::HTML(html)
pp doc.search('//tr')[2].search('td').map{ |n| n.text }
>> ["14-02-2011", "1", "3", "1", "1", "0", "0,00 DKK", ",00", "0,00 DKK"]
Use the .search('//tr')[2].search('td').map{ |n| n.text } appended to Mechanize's agent.page, like so:
agent.page.search('//tr')[2].search('td').map{ |n| n.text }
It's been a while since I played with Mechanize, so it might also be agent.page.parser....
EDIT:
there will come more rows in the table. The row that i want to scrape is always the second last.
It's important to put that information into your original question. The more accurate your question, the more accurate our answers.

Resources