Categories
Mastering Development

Need to flatten and denormalise json data in Python [closed]

I have the following json string: { “Orders”:{ “OrderNumber”:123, “OrderLines”:[ { “Item”:”Coke”, “Price”:”10″ }, { “Item”:”Fanta”, “Price”:”9″ } ] }, “TotalSale”:”19″, “TotalVAT”:”4.00″ } and would like, using Python, to write it to csv, capturing all rows and denormalising it so that all data is returned: Order,Item,Price,TotalSale,TotalVAT 123,Coke,10,19,4.00 123,Fanta,9,19,4.00 Any ideas how to achieve this?

Categories
Mastering Development

Create 2 subdivs of child Div and add Dynamic unique ID on Appended Child Divs?

I am currently building a blackjack game and each time I press “hit”, I run this function which appends divs that represents a card pulled from a deck. I am able to set a ID to the div, but I want each ID to increment in value… So div1, div2, div3. Currently, each div gets […]

Categories
Mastering Development

Rotate binary search tree after every insert java

I need to rotate the tree after every insert, and it goes well while I add only lesser/greater value than his parent. I mean, if I insert 6-4-3 the resulting tree after the 2 rotations will be (read that like a level order print) 3-4-6 and it’s ok, but if I add a greater value […]

Categories
Mastering Development

With functional programming, using fplus: error when converting vector

I am practicing functional programming, using the fplus library (https://github.com/Dobiasd/FunctionalPlus). The given vector of vectors of strings const std::vector<std::vector<std::string>> singleGradeStatisticPairsAsStr = { {“10”, “1”}, {“20”, “2”}, {“30”, “3”} }; is supposed to be converted to a vector of vector of ints. Using iterative style this could be implemented as std::vector<std::vector<int>> singleGradeStatisticPairs; for (auto singleGradeStatisticPair : […]

Categories
Bitcoin Cryptocurrency Mastering Development

Checksum P2WSH failed

My goal is replicate the same P2WSH of https://en.bitcoin.it/wiki/BIP_0173 tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7 I’m able to generate the “first” part before checksum. There are my binary 00000 00011 00001 10001 10001 01000 01111 00000 10100 11000 10100 01011 00110 10000 00001 00101 11101 00011 00100 10000 00011 00110 10101 10110 11010 00010 01101 10110 01001 10000 10101 10011 […]

Categories
Mastering Development

Varchar to Datetime in TSQL

How can I convert date and time value stored like 20200406151341 to DATETIME value 2020/04/06 15:31:41 (YYYY/MM/DD HH:MM:SS.000)? I am unable to find suitable CONVERT() format and the only way so far is to parse the VARCHAR like below. select dateadd(second, cast(substring(‘20200406151341’,13,2) as int),dateadd(minute, cast(substring(‘20200406151341’,11,2) as int), dateadd(hour,cast(substring(‘20200406151341’,9,2) as int),convert(datetime, left(‘20200406151341’,8), 112)))). It works yet […]

Categories
User Help

How to create a list in Power Query from the listed values in Excel sheet, if it has a range

I am trying to modify the Excel’s Power Query with specific rows to keep by using function Table.SelectRows(…). I have the list with numbers of rows to keep and it’s working fine, however, I can’t make that list dynamic. What I want to achieve is having a cell in Excel sheet which has rows listed […]

Categories
Mastering Development

Combining fragments of Haskell Code to get the bigger picture

So, this is the code that I came upon somewhere but want to know how this works: findIndices :: (a -> Bool) -> [a] -> [Int] findIndices _ [] = [] findIndices pred xs = map fst (filter (pred . snd) (zip [0..] xs)) Output: findIndices (== 0) [1,2,0,3,0] == [2,4], where pred is (==0) […]

Categories
Mastering Development

read a matrix from a file in python

def main(): f=open(“fileread.txt”,”r”) for x in f: p=x.split(” “) print(p) main() I have written this code for reading a matrix from a file and write it into the console. But I got unexpected output. The output should be [‘5’, ‘6’, ‘9’, ‘7’] [‘1’, ‘7’, ‘9’, ‘6’] [‘4’, ‘5’, ‘6’, ‘3’] [’14’, ’25’, ‘9’, ‘6’] but […]

Categories
Mastering Development

Create new variable in df_a based on sample from df_b

I want to create a new variable “wz” in dataframe A (df_a) and assign a value to this variable that is drawn from the same variable in dataframe B (df_b). The value should be drawn randomly with a probability that is taken from the share of “wz”. The variable “wz_share” in df_b was calculated by […]