Pivot table export excel for header group - ag-grid

How to excel export for pivot table?
Name Code shop sum1 sum2
A 1 16 2 3
B 2 14 4 3
C 4 13 2 5
D 3 33 1 6
Name, code => rowGroup / shop => pivot
Then, it looks like on the screen.
Name Code total1 total2 sum1 sum2 sum1 sum2
A 1 6 6 2 3 4 3 ...
but I export excel. It looks like
I want to export excel like this picture. What should I change to look the same as this?

I was right in my comment on the question. This is because groupHideOpenParents is not applied to the exported file. This is a known issue. It is among the "Standard Feature Requests" in the ag-Grid Pipeline: https://www.ag-grid.com/ag-grid-pipeline/. Ticket key: AG-3756 [Excel Export] Allow groupHideOpenParents to apply in Excel export
Unfortunately it is in the backlog, so it can't be known when it will be fixed and released. Based on this blog entry: https://ag-grid.zendesk.com/hc/en-us/articles/360002213531-Where-Is-My-Ticket-
"Standard Feature Requests are usually fixed within 2 to 4 releases after they have been raised."

Related

How to implement dynamic subscribers with KDB?

I'm trying to implement dynamic subscribers in a kdb-tick system whereby a subset of the events are passed to a given consumer based on a query supplied by the consumer.
For instance given a batch of events i.e.:
flip `source`channel`value!(10?`a`b`c;10?`a`b`c;10?10)
source channel value
--------------------
a a 4
b b 5
a c 4
b a 2
c c 7
c b 8
c a 5
a c 6
b a 4
b a 1
The tickerplant should only send the events without a channel of `c i.e.
source channel value
--------------------
a a 4
b b 5
b a 2
c b 8
c a 5
b a 4
b a 1
I have tried to implement this by parsing a dynamic conditional as follows:
q).tp.subscribers
hp | host isOpen port h subs
----------| --------------------------------------------------
:test:5000| test 0 5000 6 "enlist(not;(in;`channel;enlist`c))"
Whereby subs is a conditional argument to a functional select statement that is used in the following code:
.tp.send:{neg[x] y};
.tp.reval:{[batch;subscriber]
.tp.send[raze .subscriber`h] reval[parse["?[batch;",raze[subscriber`subs],";0b;()]"]]
};
// Called with event batch
.tp.broadcast:{[batch]
.tp.reval[batch]'[select from .tp.subscribers where isOpen]
};
This fails on account of batch not being addressable in a non global context through a functional select statement.
I was wondering how this functionality might be effectively achieved?
Could anyone advise me on or point me to information pertaining to a solution for this problem statement.
Your advice would very much appreciated.
Apologies if this is a newbie question.
Thanks
I think the fact that you're expecting a string form of a conditional argument is part of your problem (that in turn requires you to parse a stringified functional select and that parse assumes global).
Why not expect a list form of the conditional argument instead? Then there's no need to parse and you can create a local functional select. E.g.
.tp.subscribers:([hp:1#`:test:5000]subs:enlist(not;(in;`channel;1#`c)))
q){[batch] reval ?[batch;(0!.tp.subscribers)`subs;0b;()]}flip `source`channel`value!(10?`a`b`c;10?`a`b`c;10?10)
source channel value
--------------------
a a 4
b b 5
b a 2
c b 8
c a 5
b a 4
b a 1
Or have the user specify a lambda and run that (though I guess you would lose the ability to use reval in that case):
.tp.subscribers:([hp:1#`:test:5000]subs:enlist{select from x where not channel=`c})
q){[batch] #[first(0!.tp.subscribers)`subs;batch;()]}flip `source`channel`value!(10?`a`b`c;10?`a`b`c;10?10)
source channel value
--------------------
a b 9
c b 0
b b 0
b a 9
b a 3
b a 9

"Error: n() should only be called in a data context"

I am trying to spread my data from multiple lines to a more condensed dataset.
I have a dataset on bird nests and am trying to wrangle my data from having separate lines for juveniles and parents who have the same year and nest data entry.
Eg
Year Nest Sex Ring_Number
2009 1 M 321
2009 1 F 189
2009 1 J 232
2009 1 J 101
I want my data to instead look like as follows:
Year Nest M_Ring_Number F_Ring_Number J_Ring_Number
2009 1 321 189 232
2009 1 321 189 101
Is anyone able to help me (I am new to using R)?
Thanks
CI<-C3 %>% group_by(Nest)%>% mutate(grouped_id=1:n())
Error: n() should only be called in a data context
Call rlang::last_error() to see a backtrace
I have faced the same problem. I sensed this function is being masked by another package. So I just detach all the packages and used only this package. It worked fine. You can also try any other package that provides this kind of function like margittr. Try your luck.

fuzzy matching when dataframe are different length

they have marked this question as duplicate, but it has not answer, so trying again.
I have two datasets df2
> Page Title ... dummy
> 383 India Companies Act 2013: Five Key Points Abou... ... 1
> 384 Seven Things Every Company Should Know about A... ... 1
> 385 What Is a Low-Carbon Lifestyle, and How Can I ... ... 1
> 386 Top 10 CSR Events of 2010 | Blog | BSR ... 1
> 387 10 Social Media Rules for Social Responsibilit... ... 1
df1
title
0 Building Responsibly Announces Worker Welfare...
1 Announcing a New Collaboration Using Tech to ...
2 Sustainability Standards Driving Impact for W...
3 What the Right to Own Property Means for a La...
4 The Digital Payments Opportunity: A Conversation
5 The US$660 Billion Sustainable Supply Chain F...
6 A New Tool to Assess the Impact of Your Healt...
7 The Global Climate Action Summit: How Busines...
8 Two Ways Responsible Investors Can Promote In...
9 Where BSR Will Be in June 2018
10 Scaling a Renewable Future for Internet Power
11 How Health Training Changed Social Norms in H...
12 A Map to Help Business Collaborate with Anti-...
they have different lengths.
I tried the approach
df2['Page Title'] = df2['Page Title'].apply(lambda x: difflib.get_close_matches(x, df1.title)[0])
but I get the following error, possibly because of the different length
df2['Page Title'] = df2['Page Title'].apply(lambda x: difflib.get_close_matches(x, df1.title)[0])
IndexError: list index out of range
how to solve it?
This should work:
matched_titles = []
for row in df1.index:
title_name = df1.get_value(row,"Page Title")
for columns in df2.index:
title=df2.get_value(columns,"title")
matched_token=fuzz.partial_ratio(title_name,title)
if matched_token> 80:
matched_titles.append([title_name,title,matched_token])

Merge data from many sheets on to one

In excel, I have several sheets (around 50), each with an identical header in columns A, B and C, and then up to 199 rows of data (row 1 = header, rows 2-200 = data). The naming routine is as Wk 1 Mon, Wk 2 Tue, etc, all the way up to Wk 10 Fri
What I would like to do is display all of the data from these tabs in one list, on one sheet. I could potentially do this by referencing each cell from each sheet, one under the other, but the problem is that not all sheets actually have data right the way down to row 200 (some have just the header), and I wish to skip empty rows.
I have absolutely no clue how to approach this in Excel. My understanding of VLOOKUP and the like is rudimentary at best; I'm not sure if I could even achieve what is required by using that family of functions.
I've also looked in to the Consolidation feature of Excel, but I don't think that is what I need in this scenario.
Could someone please suggest how I may achieve my goals. I would prefer to do this via worksheet only functions, but I'd be open to VBA if there was an easy enough solution.
Try this bit of VBA. It basically scrolls through each worksheet, finds the last row and pastes it on the bottom of the first sheets data. It's a bit crude in methodology but it does work!
Dim ws As Worksheet
For Each ws In Worksheets
i = i + 1
If i = 1 Then
FirstSheet = ws.Name
ElseIf i > 1 Then
ws.Activate
LastCell = Cells(65536, 1).End(xlUp).Row
Range("A1:C" & LastCell).Select
Selection.Copy
Worksheets(FirstSheet).Activate
Cells(Cells(65536, 1).End(xlUp).Row + 1, 1).Select
ActiveCell.PasteSpecial xlPasteValuesAndNumberFormats
End If
Next ws

Odoo / Postgres: Concatenate rows value until condition = true

I'm creating a new view for a customized PoS module for my restaurant. It's a specific view for kitchen, already filtered to show just kitchen's related items of a PoS order.
Now I would like to show a particular series of product with the name starting with "#" in a field populated by a function side by side with the "standard" products. In fact I'm speaking of a set of instructions coded as products to be available on PoS and to suit my needs I decided to create kitchen instructions as a product (service). In my PoS there are 3 categories that are not products but instructions (ADD, SUBTRACT, ADDITIONAL NOTE).
A typical order will show as:
Product Quantity
[1007] Pom. Secchi 1
# + Búfala 1
# - Mussarela 1
[2002] Nutella banana 1
# + Mussarela 1
What I would like to archive is a view like:
Product Note Quantity
[1007] Pom. Secchi # + Búfala # - Mussarela 1
[2002] Nutella banana # + Mussarela 1
I need to select just the strings starting with the "#" between two internal code starting with "[code]" and this is the hard thing to do. I don't need to delete the values I "move" because I need the stock view when I print the receipt.
I will call this function using python (and psycopg2 on postgresql 9.4) with on_change or extending the workflow when an order is marked as "paid". I don't think if doing it directly in Python is viable.
I've tried with string_agg(,) but with bad results.
Any tips about what should be the correct path to start coding? Thanks.