Python Forum
Need help with arithmetic calculation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with arithmetic calculation
#1
Can some one help me with below scenario i have lot of files in a folder in linux
where i have files with data like usually that data is per host and i will try to use nfs and key
add the size_total and say total value is this much but abc.com can we in multiple other files like example it can be part of 3 servers and raj.com can be part of 2 servers wat i'm doing now is

1856757743616+3078632562688,ioo.com but i'm supposed to do some thing like 1856757743616/3 + 3078632562688/2,ioo.com and say nas size of the ioo.com is 1856757743616/3 + 3078632562688/2.
i have also mentioned my code at the end can some one help with this


ioo.com
{"device": "abc.com:/ind", "fstype": "nfs", "mount": "/ind", "size_total": 1856757743616, "uuid": "N/A"}

{"device": "raj.com", "fstype": "nfs", "mount": "/rakesh", "size_total": 3078632562688, "uuid": "N/A"}]}

path = '/home/raj/nfsstorage'
valid_fs = ['nfs','NFS']
extensions = ['.com']
my_sql_data = list()
This is my present code
for file in os.listdir(path) :
      vendor_total_size = 0L
      for extension in extensions:
         if file.endswith(extension):
                with open(file) as json_file:
                        data = json.load(json_file)
                        data_1 = data['ansible_facts']
                        size_tuple = {}
                        my_sql_json = {}
                        for j in range (0, len (data_1['ansible_mounts'])):
                                key = data_1['ansible_mounts'][j]['fstype']
                                if(key in valid_fs):
                                        hostname = file
                                        siz_num = (data_1['ansible_mounts'][j]['size_total'])
                                        if siz_num is  None:
                                           continue
                                        elif siz_num:
                                           vendor_total_size = vendor_total_size + siz_num / 1073741824
                                           size_tuple[key] = vendor_total_size
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Evaluating arithmetic expression with recursion. muddybucket 3 2,829 Dec-17-2021, 08:31 AM
Last Post: deanhystad
  Simple arithmetic question ebolisa 5 2,038 Dec-15-2021, 04:56 PM
Last Post: deanhystad
  Magic Method Arithmetic Operators ClownPrinceOfCrime 3 2,312 Jan-10-2021, 03:24 PM
Last Post: ndc85430
  floating point arithmetic exDeveloper 2 2,108 Sep-25-2019, 04:33 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020