DataXtractor is a versatile Python library designed to simplify the extraction of valuable data from a variety of sources, including images and PDF documents. Whether you need to extract text, tables, or structured content, DataXtractor provides powerful and intuitive tools to streamline the process.
Project description
DataXtractor Library
DataXtractor is a versatile library designed to extract text from PDF documents, with the ability to handle images and multi-column layouts. This README file provides an overview of the library's capabilities and how to use it effectively.
Features
DataXtractor library offers the following key features:
1. Image to Text Extraction
DataXtractor is equipped to handle PDFs containing images. It utilizes Optical Character Recognition (OCR) to convert images embedded in PDF files into machine-readable text. This allows you to access and manipulate the textual content within images present in your PDF documents.
2. Multi-Column Text Extraction
In case your PDF contains text arranged in multiple columns, DataXtractor allows you to extract this text intelligently. The library can separate and extract content from each column independently, making it possible to obtain text in a structured and organized manner.
3. Language Support
DataXtractor supports multiple languages for OCR operations. You can specify the language code string using the lang
parameter. By default, the library uses English (eng
) if the language is not specified. You can also specify multiple languages for a more comprehensive text extraction process. For example:
supported_language_codes = [
"ara", "aze", "aze_cyrl", "bel", "ben", "bod", "bos", "bul", "cat", "ceb", "ces", "chi_sim", "chi_sim_vert", "chi_tra",
"chi_tra_vert", "chr", "cym", "dan", "deu", "deu-frak", "ell", "eng", "enm", "epo", "est", "eus", "fas", "fil", "fin",
"fra", "frk", "frm", "fry", "gle", "glg", "grc", "guj", "hat", "heb", "hin", "hrv", "hun", "hye", "iku", "ind", "isl",
"ita", "ita-old", "jav", "jpn", "jpn_vert", "kan", "kat", "kat-old", "kaz", "khm", "kir", "kor", "kor_vert", "lao",
"lat", "lav", "lit", "ltz", "mal", "mar", "mkd", "mlt", "mon", "mri", "msa", "mya", "nep", "nld", "nor", "oci", "ori",
"osd", "pan", "pol", "por", "pus", "ron", "rus", "san", "sin", "slk", "slv", "snd", "spa", "spa_old", "sqi", "srp",
"srp_latn", "sun", "swa", "swe", "syr", "tam", "tat", "tel", "tgk", "tha", "tir", "ton", "tur", "uig", "ukr", "urd",
"uzb", "uzb_cyrl", "vie", "yid", "yor"
]
This is especially useful when working with PDFs that contain text in various languages.
4. PDF Text Extraction
DataXtractor is not limited to image-based PDFs. It can also extract text directly from PDF documents that contain text content. This feature allows you to process PDF files, whether they contain text alone or a combination of text and images.
Getting Started
To get started with the DataXtractor library, follow these steps:
-
Installation: Install the DataXtractor library by using the provided package manager (if available), or manually include it in your project.
-
Library Initialization: Initialize the DataXtractor library in your code, specifying the language(s) to use for OCR, as well as any other required parameters.
-
PDF Processing: Load your PDF document and apply the appropriate extraction functions based on your needs. For image-based PDFs, use OCR to convert images to text. For text-based PDFs, extract text directly.
-
Output Handling: Receive the extracted text and use it as needed for further processing or analysis within your application.
You can convert a PDF into an image and then perform OCR on that image using two different languages. Additionally, you can crop the image into two parts for separate OCR processing.
Example
from pdf2image_dataextraction import data_extraction2parts
path = "sample.pdf"
left_partition = "40"
right_partition = "60"
lang_part_first = "en"
lang_part_second = "en"
data = data_extraction2parts.DATA_EXTRACTION_2_Columns(
path, left_partition, right_partition, lang_part_first, lang_part_second
)
print(data)
path = "sample.pdf"
top_partition = "40"
bottom_partition = "60"
lang_part_first = "en"
lang_part_second = "en"
data = data_extraction2parts.DATA_EXTRACTION_2_Rows(
path, left_partition, right_partition, lang_part_first, lang_part_second
)
print(data)
# split the pdf images into too many parts
pdf_path = "sample.pdf"
w_size = "3"
h_size= "3" # they will cut the pdfimages into 3 * 3
split_files=data_extraction2parts.split_pdfimage_into_folders(
pdf_path, w_size, h_size, output_folder
)
You can convert a PDF into an image and then perform OCR on that image and extract Data
from pdf2image_dataextraction import data_extract
path = "sample.pdf"
data = data_extract.DATA_EXTRACTION(
path
)
print(data)
You can also extract data from PDF
from pdf_dataextraction import data_extraction_pdf
path = "sample.pdf"
data = data_extraction_pdf.extract_text_from_pdf(path)
print(data)
You can also extract data from images
from image_dataextraction import data_imageextraction
path = "sample.jpeg"
data = data_imageextraction.Image_extraction(path)
print(data)
# split the pdf images into too many parts
pdf_path = "sample.jpeg"
w_size = "3"
h_size= "3" # they will cut the images into 3 * 3
split_files= data_imageextraction.split_image_into_folders(
pdf_path, w_size, h_size, output_folder
)
Contribute
If you find any issues or want to contribute to the DataXtractor library, please check the project's repository for information on how to get involved.
License
This library is released under the MIT License to encourage collaboration and use in various applications.
DataXtractor is a powerful library for extracting text from PDF documents, whether they contain images, multi-column layouts, or plain text. It supports multiple languages and can be a valuable tool for text extraction and data analysis in a wide range of applications.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for DataXtractor-1.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d05a905a9f5d8e7a6b21ed5f4bc4081c921d9d9005c5157dfcd55c76e1b2026e |
|
MD5 | c19284749ce126585369e3a664598f97 |
|
BLAKE2b-256 | 27e06d1fe6cf5929087e85dd2b611abe848c5afb5bc6a8b002d9b5e2612e6016 |