File size: 1,536 Bytes
ba010f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4d9431
 
 
 
 
1fd0231
 
 
 
 
 
 
 
 
 
 
 
 
b5eb5f4
 
1fd0231
 
b5eb5f4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import time
import psutil
import pandas as pd
import numpy as np

def get_stats(file_path):
    if os.path.exists(file_path):
        data = pd.read_csv(file_path)
    else:
        columns = ['Timestamp', 'MemoryUsed(%)', 'CPU_Used(%)']
        data = pd.DataFrame(columns=columns)
    while True:
        current_time = time.strftime("%d_%m_%y_%H_%M_%S")

        # Memory stats
        memory_stats = psutil.virtual_memory()
        memory_used = memory_stats.percent

        # CPU stats
        #cpu_stats = psutil.cpu_percent(interval=1, percpu=True)
        cpu_stats = np.mean(psutil.cpu_percent(interval=1, percpu=True))
        # Create a new row with the timestamp, memory stats, and CPU stats
        new_row = {'Timestamp': current_time, 'Memory Stats': memory_used, 'CPU Stats': cpu_stats}

        # Append the row to the DataFrame
        data = data.append(new_row, ignore_index=True)

        # Sleep for 60 seconds
        time.sleep(5)

        # Save the DataFrame to a CSV file
        data.to_csv(file_path, index=False)



page_dict = {}

page_files = [
    'doc/344_page_1_txt.png',
    'doc/344_page_1_table.png',
    'doc/5433_page_2_table.png',
    'doc/54_page3_img.png',
    'doc/32_page3_txt.png',
    'doc/32_page3_table.png'
]

for file in page_files:
    # Extracting page number from file name
    page_number = file.split('_')[1].replace('page', '')
    
    if page_number not in page_dict:
        page_dict[page_number] = []
    
    page_dict[page_number].append(file)

print(page_dict)