Oct-16-2018, 01:10 PM
I have written the contents of a dictionary to a text file. Each key stores a list. I'm having trouble reading the list, however. I only want what was the second item on the list. Here's some code and the contents of the text file that the script reads from:
I can't figure out how to find the comma and then read only the numbers after the comma. I don't want the brackets or the spaces.
Thanks in advance for any help.
-malonn
def write_dumps(self): dmp = self.scan_dumps() i = 0 with open('practice_gui_2.ini', 'w') as f: while i < len(dmp): s = str(dmp[i]) f.write(f'{s}\n') i += 1 def get_size(self): '''Reads fro Ini created by "scan_dumps()" and gets total size of all .DMP files to display in the GUI.''' with open('practice_gui_2.ini', 'r') as f: s = f.readline() l = s.find(',') ...
['C:\\Games\\Steam\\dumps\\assert_steam.exe_20181011101734_1.dmp', 451628]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.1008.dmp', 23099764]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.2520.dmp', 22764743]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.3180.dmp', 22698987]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.3800.dmp', 23833275]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.4268.dmp', 24042924]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.6068.dmp', 22672263]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.6204.dmp', 23633874]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.6500.dmp', 21915672]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.7360.dmp', 22779161]
['C:\\Users\\Mark\\AppData\\Local\\CrashDumps\\StaxRip.exe.8052.dmp', 22445275]
['C:\\Windows\\System32\\config\\systemprofile\\AppData\\Local\\CrashDumps\\lsass.exe.796.dmp', 844132]
I can't figure out how to find the comma and then read only the numbers after the comma. I don't want the brackets or the spaces.
Thanks in advance for any help.
-malonn