Author name: Paras Agarwal

Data Science

How to Convert PDF File to Text File Using Python

We do not require any further software or a specific application or Google search for changing a PDF to a text document.   The process of converting a PDF file into a text document using python is as follows:     Step to Convert PDF to Text in Python   Step 1- Install the library   We need only one external module or package for this which is PyPDF2.   PyPDF2 is a module in python which is used to perform various operations on PDF files, such as, extracting document information from a file, merging pdf, splitting pdf, overlying and watermarking pages, and encrypting and decrypting pdf files.   First, we install the library for that using pip by executing the following command in the command prompt.   pip install PyPDF2     Step 2- Import the installed library   After installing the PyPDF2 module we want to import that library using the Import keyword.   Import PyPDF2   Step 3-Open your PDF file to read   Now, we are going to open the PACKSLIP.pdf file just by calling the open () method in the ‘rb’ mode.   read_pdf = open(r”D:PracticePACKING SLIP.pdf”, ‘rb’)   Step 4-Create a PdfReader object   We will create a pdfReader object using the PdfFileReader() function defined in the PyPDF2 module.   pdfReader object will read the file opened from the previous step.   pdfReader = PyPDF2.PdfFileReader(read_pdf)   Step 5-looping to get all pages from PDF   To get the number of pages in the PDF file we use the getPage () method, which stores the number of pages in the pageObject variable. We wanted to get the text from page 1 to page 5. So, we use for loop with the range() function to get all pages used in the PDF file. pageObject = pdfReader.getPage (i)   Step 6-Extract text from page using extractText () object   After getting pageObject we will use the extractText () method to extract all the text from the PDF file.   extract_text=pageObject. extractText ()     Here is the Complete Code for extracting text from a PDF file using the PyPDF2 module in Python:-         Output:-   This is the source PDF file location.   The source PDF files, which we are using, is PACKSLIP.pdf and will be converted into a text file         If we open this you see here this is kind of 5-page document.         In this output terminal, it shows the total number of pages which is 5, and shows data as you can see in the above picture.         Extracted data file:-   This is the location where extracted data is store in text file name PACKINGSLIP.txt       When we executed the script we generated a PACKSLIP text file. We will open this file and here we can see that our text file carry all the content from our PACKSLIP.pdf file.             This is the final step to transform our PDF into a text file.   Conclusion:   This blog explains how to convert a file from PDF format to text format. We have used python for this purpose because it has a wide variety of tools and libraries that contains in-built modules that make our work simpler and easier. Using python is justified since the code written is automated and executes our process in a single go.

Data Science

Mastering Report Creation with SAP Crystal Reports

  Crystal Reports is a BI tool provided by SAP and it is an interface that enables you to quickly and easily create, format and publish effective reports.   It is a very robust tool it proudly can do everything and anything in terms of how to present your forms invoice sales orders things of that nature and create executive reports to make a better business decision.   We created a crystal report viewer in SAP business one. This is the viewer that allows us to view various crystal reports. There is a report and layout manager that allow us to import and export crystal reports.   Crystal reports allow you to save forms in SAP business one and preview them within an SAP business.   HOW TO USE CRYSTAL REPORTS   First, we need crystal report software on our system to open this software.   Now, we are going to create a report.   Open SAP Crystal Report Application For Build Crystal Reports.   In the file, menu click New and then click on Standard Report.       Once we start building a report, we select the data source.   Inside the field explorer, we will find the database field and right-click the database expert. Inside our database expert         click on creates new connections option. It will show several database connections, such as the EXCEL, XML, ODBC, etc.   Next, select OLDB. Here inside an OLDB, there are many databases. Now, select Native Client 11.0 provider for SQL Server   and click next.       In the next window, mention the Server name, User ID, and Password, and Database name, and then click on finish.   After connecting the database we will see the list of available tables.       Now, we select tables that we want to use for the crystal report. We can add more than one table according to our requirement       The next page will give us the option to create joins between selected tables using common columns.   We also notice some of these columns have little flags in front of them these indicate   Index or key column, so if we join tables based on these columns then the database performance will be better.       Once we are on the design screen we are going to set up our report. Now, we have a blank report.   In our report layout, we have the report header at the top of first page and page header at the top of each page of the report.   Then we have the detail tab in which we fetch the data. The report footer is at the end of the last page and the page footer appears at the bottom of each page.   Field explorer gives us the access to all column in tables and also give us the ability to build formulas for mathematical   Calculation, such as, running totals or summaries and build parameters that are passed to   the end-user.     Here, we created an amazon bill slip using crystal report. We simply put the report header and page header using a text object   from the menu bar. In the detail section, we want to pull columns from different tables to fulfill our report needs.   We simply drag and drop fields from the field explorer to pull some basic information.       After done with the designing part, we are going to preview this report. We will go to view and then select the Print Preview and it will build the report         Here is the final report preview.     CONCLUSION:   Our blog expounds on the method to build a crystal report using the SAP Crystal Report tool, in which by following a few simple steps we will be able to fetch meaningful data by easily generating invoices.

Activate Your Free 15-Day Infominer Trial

X
Scroll to Top