import ast import pandas as pd # Path to your .txt file txt_file = 'output_eos.txt' # Read the .txt file with open(txt_file, 'r') as file: data = file.readlines() # Filter the data filtered_data = [] for line in data: try: # Convert the string into a tuple tuple_data = ast.literal_eval(line.strip()) # Check if the second value is greater than 10 #if tuple_data[1] > 1: filtered_data.append(tuple_data) except: continue # Handle any parsing errors # Convert the filtered data into a DataFrame df = pd.DataFrame(filtered_data, columns=['Variable', 'Value']) # Save the DataFrame to an Excel file df.to_excel('filtered_scrape_data.xlsx', index=False) print("Excel file created successfully!")