Exclude "Total" row in Google AdWords performance report - google-ads-api

I am downloading Ad Performance reports (in CSV format) using the .NET client library for Google AdWords API v201209.
The final row of data in every report I download is an aggregate row. An example looks like:
Total, --, --, --, --, --, --, --, --, --,2.6, --, --, --,516,13,16
I do not need the aggregate data. Currently I'm stuck having to write code to remove it manually or deal with skipping this row during parsing.
Is there a way to exclude this row from being included in the downloaded report?

For php users that uses googleads-php-lib:
$reportUtils = new ReportUtils();
$report = $reportUtils->DownloadReport($reportDefinition, null, $user, array('skipReportSummary'=>true));

Not possible at the moment, I'm afraid. I usually request a numeric field at the beginning of each row, so I can filter out rows that I don't want; this also works for the header rows, which can't be removed either.

I use version 201509. You can suppress Totals as well as Report Header and Column Headers in report_downloader parameters
report_downloader.DownloadReport(
report, outputfile,
skip_report_header=True,
skip_column_header=False,
skip_report_summary=True,
include_zero_impressions=False)

As of now, you can set an HTTP header:
skipReportSummary: true|false | If true, report output
will not include a summary
row containing the report
totals. If false or not
specified, report output
will include the summary row.

Related

How to Automatically convert a String YYYY|MM Column to a Date Column YYYY/MM on Google Sheet?

I am pulling data with a Plugin called Supermetrics from Adobe Analytics to Google Sheet.
The Date column is pulled as String and I want to create automatically another column that is reading and converting this column to a Date Format
Input
Year & month First touch channel Visits
2018|12 Natural Search 12345
2019|01 Natural Search 56789
2019|02 Natural Search 23456
2019|03 Natural Search 78912
2019|04 Natural Search 34567
Expected Output
Year & month First touch channel Visits Year & month_dt
2018|12 Natural Search 12345 2018|12
2019|01 Natural Search 56789 2019|01
2019|02 Natural Search 23456 2019|02
2019|03 Natural Search 78912 2019|03
2019|04 Natural Search 34567 2019|04
I don't need to do manually by clicking on the menu -> Format->Date
I need a way to do automatically and possibly without conflicts with the plugin, because the data are going to be refreshed daily.
You can use this array formula in the table header
={"Year & month_dt";ArrayFormula(if(A2:A<>"", DATE(LEFT(A2:A,4),RIGHT(A2:A,2),1),))}
in order to convert the received dates to your desired format - apply the YYYY|MM date format once for the whole column

How to get child nodes through importxml xpath query?

I'm trying to get the seperate <td>'s to show up in Google Sheet of a <tr> that I'm importing through IMPORTXML.
This code should get my match data based on the match ID I provide, and my player ID. I feel that simply adding /* or /td to end of Xpath should work, but that's the end of my knowledge.
I tried: adding /*, /td and other to end of xPath Query but doesn't seem to work.
Even disabled JavaScript and inspected website again but to no avail.
FORMULA:
=IMPORTXML("https://www.dotabuff.com/matches/5011379854";"//tr[contains(#class,'9764136')]")
Also tried:
=IMPORTXML("https://www.dotabuff.com/matches/5011379854";"//td[parent::tr[contains(#class,'9764136')]]")
Which only gives the first of all the /td's and not the rest.
Current outputis all mushed together:
"19LemthTop (Off)ZeusCoreTop (Off) Roaminglost27108.7k127933650626.5k-183-/-5m7m21m31m"
The output that I want is separate <td> on separate lines:
"19
LemthTop (Off)ZeusCoreTop (Off) Roaminglost
2
7
10
8.7k
127
9
336
506
26.5k
-
183
-/-
5m7m21m31m"
Issue and workaround:
Although I have tried to parse the values for each row, unfortunately, it seemed that td cannot be directly parsed using a xpath with IMPORTXML as each row. But fortunately, each table can be retrieved by IMPORTHTML and also each tab can be accessed. Using them, how about the following workaround?
Retrieve a table from the URL using IMPORTHTML.
Retrieve a row including the name corresponding to 9764136 you want using a query.
Modified formula:
=TRANSPOSE(SPLIT(TEXTJOIN("#",TRUE,QUERY(IMPORTHTML(A1,"table",1), "where Col4 contains '"&IMPORTXML(A1,"//a[contains(#href,'9764136')]")&"'", 0)),"#",TRUE,TRUE))
The URL of https://www.dotabuff.com/matches/5011379854 is put to the cell "A1".
After the table was retrieved, the row is retrieved from the table by the query.
The important point of this workaround is the methodology. I think that there are various formulas for retrieving the value. So please think of above sample formula as just one of them.
Result:
Note:
If you use above formula for other URL, an error might occur. Please be careful this.
References:
IMPORTHTML
IMPORTXML
TEXTJOIN
SPLIT
TRANSPOSE

Google BigQuery exports numeric data with wrong decimal to Sheets

In our workflow we often export results from a query on BigQuery to Google Sheets, e.g. for distribution to customers in .xlsx format.
I'm running into something weird: when explicitly casting the output of a query to numeric, the export in Sheets gives errors in for the decimals.
For example,
select
cast('12.3' as numeric),
cast('12.34' as numeric),
cast(12.056 as numeric),
cast('12.345786' as float64)
Yields the following query result in the WebUI
Row f0_ f1_ f2_ f3_
1 12.3 12.34 12.056 12.345786
However, the result in Google Sheets (again, using the WebUI, option Save to Sheets), is this:
f0_ f1_ f2_ f3_
12.3 1234 12056 12345786
Only pattern I can see is that the decimal sign is erroneously dropped when there are two or more decimals.
I really have no clue what is causing this, let alone how to fix it. Exporting the data to .csv and .json does yield the correct result.
Help, anyone?

Month calculation in neo4j

I am working in neo4j database.
i have csv file column is ENTRY_DATE format is "08-apr-15" String type date.and current date format is "21-10-2016".How to change the String type Entry_date is like current date format.but my need is compare the current date with entry_date column then calculate the difference of month between two dates.
You can parse both strings using Cypher's string functions.
WITH {current_date} AS current_date
WITH split(current_date, '-') AS month_tuple
WITH month_tuple[1] AS c_month, month_tuple[2] AS c_year
WITH {jan: 1, feb: 2, ... dec: 12} AS month_map, c_month, c_year
LOAD CSV WITH HEADERS FROM "place" AS row
WITH row, row.ENTRY_DATE as e_date, c_month, c_year, month_map
WITH row, c_month, c_year, split(e_date, '-') AS e_tuple, month_map
WITH row, c_month, c_year, e_tuple[2] AS e_year, e_tuple[1] AS e_month_key, month_map
WITH row, (toInt(e_year) -toInt(c_year)) * 12 as year_diff, month_map[e_month_key] - toInt(c_month) AS month_diff
WITH row, year_diff + month_diff AS months_later
But InverseFalcon is definitely right in that this would be way better if handled through the backend. Clean up your CSV before import and pass in a better source of current date and you can cut most of that query out.
Neo4j doesn't have much support for date/time operations at all. If your backend framework/language has good date/time support, I'd recommend doing that calculation there instead of from the db itself.
But if you are looking for a pure neo4j solution, the APOC Procedures library has some conversion and formatting support, but if that's not enough, you may want to look at GraphAware's neo4j timetree. That should give you some graph operations for finding the years or months between different dates.

Using Google Spreadsheet API without having values in header row in lower case with spaces removed

I was wondering if there is any way around (read: hacks) using the Google Spreadsheet API that doesn't impose the restriction of having the values in the header row in lowercase with no spaces.
I'm aware that I can just make use of the cell based feed but that would have an overhead of my application having to track what column number corresponds to a particular column name.
Does anyone have an alternative means?
(Also I noticed that the Google Spreadsheet API Docs doesn't make any mention of the header row name restriction, I had to search around to find out why my code wasn't working initially)
You don't have to actually change any headers in your spreadsheet and bent to some restrictions. Basically the API transforms your headers into the "lowercase no-space" format and you can access them as such. So trying to access a column with a header "My Header" would work by querying the column "myheader". The headers in the original spreadsheet remain unchanged and in the desired format.
#header_names = list of header names
spreadclient = gdata.spreadsheets.client.SpreadsheetsClient(source='Your App Name')
#Add a line to authenticate the spreadsheet client
spreadsheet_key = spreadsheet.GetId().split("%3A")[1]
worksheets = spreadclient.GetWorksheets(spreadsheet_key)
#get worksheet id
wsid = worksheets.entry[0].GetWorksheetId()
#header row can only be accessed via cellfeed
for i,name in enumerate(header_names):
cellentry= spreadclient.GetCell(spreadsheet_key, worksheet_id=wsid, row_num=1, col_num=1+i)
#update value
cellentry.cell.input_value = name #TODO: do batch update instead
spreadclient.update(cellentry)

Resources