How to Extract Specific Portions of a Text File Using Python. Computerhope.com Python 3 string objects have a method called rstrip(), which strips characters from the right side of a string.The English language reads left-to-right, so stripping from the right side removes characters from the end. If the variable is named mystring, we can strip its right side with mystring.rstrip(chars), where chars is a string of characters to strip. Extracting Text from PDF File Python package PyPDF can be used to achieve what we want (text extraction), although it can do more than what we need. This package can also be used to generate, decrypting and merging PDF files. It will extract all the files in zip at current Directory. If files with same name are already present at extraction location then it will overwrite those files. Extract all files from a zip file to different directory. To extract all the files from zip file to a different directory, we can pass the destination location as argument in extractall(). In Python Advanced #10, we read two columns from a non-justified text file and saved those values into lists. Recall that the non-justified text file was as follows: Using the code developed in Python Advanced #10 and adding code to write the results of the lists named vals1 and vals2 to a text file, the code is as follows: This is a list of file signatures, data used to identify or verify the content of a file. Such signatures are also known as magic numbers or Magic Bytes. Many file formats are not intended to be read as text. If such a file is accidentally viewed as a text file, its contents will be unintelligible.