Hi I have given below data but its unindent only using total keyword I can find the right nodes and can build tree structure. Input:
Current Assets
Cash
Checking 583961
Savings 224600
Petty Cash 89840
Total Cash 898402
Accounts Receivable 3593607
Work in Process 589791
Other Current Assets
Prepaid Rent 164593
Prepaid Liability Insurance 109728
Total Other Current Assets 274321
Total Current Assets 274321
I am looking for below Output:
{
"Current Assets": {
"Cash": {
"Checking": 583961,
"Savings": 224600,
"Petty Cash": 89840,
"Total Cash": 898402
},
"Accounts Receivable": 3593607,
"Work in Process": 589791,
"Other Current Assets": {
"Prepaid Rent": 164593,
"Prepaid Liability Insurance": 109728,
"Total Other Current Assets": 274321
},
"Total Current Assets": 5356121
}
}
I tried recursion and node concept but nothing worked, It will be great if someone can help me on that trying to achieve using Python.
Rules:
As an example :
Actually work in process
is not sub item of Account Receivable' Its item of
current asset only.
As "work in progress" have digit at its end hence no children of it.
As per input data Cash does not have any numeric value at end hence such entries will have child/children,
cash is ending once having total cash with numeric value.
There will not be any children of work in process or Accounts Receivable as they are ending with Numeric value at end
Work in Process
be its own item and not a sub item ofAccounts Receivable
? There's nothing automatic that will know that. Since you didn't show what you have tried, we can't even infer your thinking about this.1000
, or1320
and where did they come from?work in process
is not sub item ofAccount Receivable' Its item of
current asset only. As "work in progress" have digit at his end hence no children of it.Cash
is end withtotal cash'. Hence
Accounts Receivable` andwork in process
will be new immediate children ofCurrent Assets
. There will not be any children ofwork in process
orAccounts Receivable
as they are ending with Numeric value at end