0

I want to store all the table values in list of lists. Could any one suggest

Acc_no    acc_name    acc_open_date   balance
123           Michel           10-05-2018        500000
456           Thamas         15-07-2016         40000
789            Gills               12-12-2019        15000

[
[123 ,          'Michel ',          '10-05-2018',        500000],
[456 ,          'Thamas',         '15-07-2016',         40000],
[789,            'Gills',               '12-12-2019',        15000]
]

Once the values stored in list of lists, I need to update balance using acc_no in list.

Ex: After one transaction the balance of acc_no 123 reduced to 450000 from 500000

[
[123 ,          'Michel ',          '10-05-2018',        450000],
[456 ,          'Thamas',         '15-07-2016',         40000],
[789,            'Gills',               '12-12-2019',        15000]
]
luigigi
  • 4,146
  • 1
  • 13
  • 30
  • are you sure you really want that? data is stored in a dataframe for a reason – luigigi Jun 11 '20 at 10:58
  • Yeah. Actually date is stored in CSV format. So I need to update the certain fields like balance and again data need to be stored in CSV file – user13723838 Jun 11 '20 at 11:00
  • Does this answer your question? [Pandas DataFrame to List of Lists](https://stackoverflow.com/questions/28006793/pandas-dataframe-to-list-of-lists) – Sid Jun 11 '20 at 11:00
  • No. CSV file contains multiple records with same account number but different balances. I would like to do the group by operation after once data stored in python – user13723838 Jun 11 '20 at 11:09
  • what? in what data structure is the data right now? in a csv file or a dataframe? – luigigi Jun 11 '20 at 11:10
  • CSV file... Need to load to python either lists or dictionary – user13723838 Jun 11 '20 at 11:12
  • then I recommend to use `pandas`. it is made for this purpose – luigigi Jun 11 '20 at 11:13
  • Thanks. But how to update the value of balance ie., consolidated values. – user13723838 Jun 11 '20 at 11:15
  • please take the time to describe your problem in more detail and what exactly you want to achieve. it is not clear from the question or the comments – luigigi Jun 11 '20 at 11:18
  • Here python script will read CSV line by line and it has to check whether account number is existed or not. If not it has to create a new entry else the balance need to be updated based on account number. – user13723838 Jun 11 '20 at 11:18

0 Answers0