I exported many reports from my system in xls in the same specific format and need to change them to another format:
Basically for every item description I need to insert the corresponding Account series it is in column J using pandas.
| Data | CP | N0 | N1 | ITEM | DEBIT | CREDIT | NET | D/C |
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |
| Account: (663) | | | | | | | | |
| 31/10/2022 | 595 | | 12 | ITEM DESCRIPTION 4859 | 5.564,40 | | 59.786,28 | C |
| Account: (664) | | | | | | | | |
| 31/10/2022 | 596 | | 12 | ITEM DESCRIPTION 234243 | 3.475,34 | | 15.492,41 | D |
| 31/10/2022 | 103 | | 14 | ITEM DESCRIPTION 456456 | | 0,01 | 15.492,40 | C |
| Account: (678) | | | | | | | | |
| 31/10/2022 | 597 | | 12 | ITEM DESCRIPTION 2332 | 6.555,27 | | 71.503,39 | C |
| Account: (689) | | | | | | | | |
| 31/10/2022 | 608 | | 13 | ITEM DESCRIPTION 66546 | 266.516,00 | | 504.013,87 | D |
| 31/10/2022 | 608 | | 13 | ITEM DESCRIPTION 57567 | 5.578,67 | | 7.656.192,54 | D |
| Account: (500) | | | | | | | | |
| 31/10/2022 | 608 | | 13 | ITEM DESCRIPTION 345345 | 54.405,00 | | 645.175,00 | D |
I tried to write a script but couldn't fetch a logic to fill the column. Could someone help me?
Desired format:
| Data | CP | N0 | N1 | ITEM | DEBIT | CREDIT | NET | D/C | Account |
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |
| Account: (663) | | | | | | | | | |
| 31/10/2022 | 595 | | 12 | ITEM DESCRIPTION 4859 | 5.564,40 | | 59.786,28 | C | Account: (663) |
| Account: (664) | | | | | | | | | |
| 31/10/2022 | 596 | | 12 | ITEM DESCRIPTION 234243 | 3.475,34 | | 15.492,41 | D | Account: (664) |
| 31/10/2022 | 103 | | 14 | ITEM DESCRIPTION 456456 | | 0,01 | 15.492,40 | C | Account: (664) |
| Account: (678) | | | | | | | | | |
| 31/10/2022 | 597 | | 12 | ITEM DESCRIPTION 2332 | 6.555,27 | | 71.503,39 | C | Account: (678) |
| Account: (689) | | | | | | | | | |
| 31/10/2022 | 608 | | 13 | ITEM DESCRIPTION 66546 | 266.516,00 | | 504.013,87 | D | Account: (689) |
| 31/10/2022 | 608 | | 13 | ITEM DESCRIPTION 57567 | 5.578,67 | | 7.656.192,54 | D | Account: (689) |
| Account: (500) | | | | | | | | | |
| 31/10/2022 | 608 | | 13 | ITEM DESCRIPTION 345345 | 54.405,00 | | 645.175,00 | D | Account: (500) |
2条答案
按热度按时间5t7ly7z51#
试试这个:
vyu0f0g12#
这不是最“复杂”的方法,但因为找到最有效的方法在这里可能并不重要,所以应该可以很好地工作: