Advertisement
Python253

pml2txt

Apr 13th, 2024
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Filename: pml2txt.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. This script converts a Process Monitor Log (PML) file (.pml) to a text file (.txt). It reads the content of the .pml file and writes it to a .txt file.
  9.  
  10. Usage:
  11. - Ensure Python 3.x is installed on your system.
  12. - Save the pml2txt.py script to a directory of your choice.
  13. - Open a terminal or command prompt.
  14. - Navigate to the directory where the pml2txt.py script is saved.
  15. - Run the script using the following command:  'python pml2txt.py'
  16. - After successful execution, a .txt file with the same name as the input .pml file will be created in the same directory.
  17.  
  18. Requirements:
  19. - Python 3.x
  20.  
  21. """
  22.  
  23. import os
  24.  
  25. def convert_pml_to_txt(pml_file):
  26.     """
  27.    Converts a Process Monitor Log (PML) file (.pml) to a text file (.txt).
  28.  
  29.    Args:
  30.    - pml_file (str): Path to the input .pml file.
  31.  
  32.    Returns:
  33.    - None
  34.  
  35.    """
  36.     # Define the output file path
  37.     txt_file = os.path.splitext(pml_file)[0] + '.txt'
  38.    
  39.     # Read the content of the .pml file using 'latin1' encoding
  40.     with open(pml_file, 'r', encoding='latin1') as pml:
  41.         pml_content = pml.read()
  42.    
  43.     # Write the content to a .txt file
  44.     with open(txt_file, 'w', encoding='utf-8') as txt:
  45.         txt.write(pml_content)
  46.  
  47. # Example usage: Convert 'demo.pml' to .txt
  48. convert_pml_to_txt('demo.pml') # Replace 'demo' with your filename.
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement