Multiple files reading

Joaquin Alzola Joaquin.Alzola at lebara.com
Tue Jun 14 16:06:07 EDT 2016


>> The dictionary that I am using in the classes:
>> {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3',
>> 'DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0
>> ,'5012':0}}
>>
>> Wanted help from your side on how to focus this just because I want to read the files once (not 6 times) and then use classes to get back the dictionary value ...
>>
>> I need just advice on steps to follow...
>>
>Use a dict (or defaultdict) where the key is the country and the value is info (class?) related to that country.

Putting a dict for each country such as:
self.dictionaryNL = {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3','DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0,'5012':0}}
 self.dictionarySP = {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3','DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0,'5012':0}}
 self.dictionaryUK = {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3','DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0,'5012':0}}
 self.dictionaryFR = {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3','DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0,'5012':0}}
 self.dictionaryDK = {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3','DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0,'5012':0}}
 self.dictionaryGR = {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3','DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0,'5012':0}}

makes the trick but I have to repeat 6 time all the time. Now with that config I read only once the files saving 125k read lines.

But as always I think it can be done better (just started to learn python about 8 month ago). Thanks for the tips.

BR

Joaquin

This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.



More information about the Python-list mailing list