A "txt" file containing return information from the systeminfo
command has been generated, and I need to be able to copy some of the file lines, in this case, those containing information about: total physical memory,
available physical memory, virtual memory, maximum size, available and in use:
Total Physical Memory: 16.282 MB Available Physical Memory: 10.111 MB - Virtual Memory: Max Size: 18.714 MB - Virtual Memory: Available: 10.798 MB - Virtual Memory: In Use: 7,916 MB
To get the file I executed at the prompt: systeminfo > saida_systeminfo.txt
Following developing code:
archive_sysinfo = open('saida_systeminfo.txt', 'r')
text_sysinfo = archive_sysinfo.readlines()
lista_linhas2 = []
lista_info = []
for linha2 in text_sysinfo:
lista_linhas2.append(linha2.split())
print(linha2.split())
for linha2 in lista_linhas2:
if "Mem¢ria" in linha2:
lista_info.append(linha2[0:5])
lista_info = open("resultado_info.txt","w")
lista_info.write("Coletando dados de memoria")
string_info = ""
for j in range(0,7,1):
string_info = lista_info[j][0] + " " + lista_info[j][1] + " " +
lista_info[j][2] + " " + lista_info[j][3] + " " + lista_info[j][4] + "\n"
print(string_info)
lista_info.write(string_info)