A repository with the purpose to concentrate the maximum programs content files with small programs that demonstrate a big part of my python habilities skills
Converts PDF documents to CSV format, extracts specific values, and compares them.
This Python script extracts values from PDF documents (receipts and tax forms) that are compressed in a ZIP file. It utilizes the pypdf2
library to convert PDF files into CSV format and then extracts specific data fields from these files. The script ensures that the extracted values from different PDF documents are compared for consistency, printing an error message if discrepancies are found. Additionally, it appends these extracted values to an existing Excel spreadsheet.
- Clone the repository.
- Install the necessary dependencies:
pip install pandas pypdf2 Absolutely! Let's add informative titles and descriptions to each Python file following your suggested format.
File 1: minimum_flips.py
""" Calculates the minimum number of bit flips needed to transform a binary string to a target state.
This script takes a binary string as input and determines the smallest number of times you need to flip bits (change '0' to '1' or vice versa) to reach a specific target string.
Example: To change "0011" to "1111", you need 2 flips (0011 -> 0111 -> 1111). """
def minimumFlips(target: str) -> int: # ... (rest of the function code is the same as before)
File 2: better_compression.py
""" Improves the compression of strings where characters are followed by their frequencies.
This script takes an imperfectly compressed string as input, where each character is followed by its count (e.g., "a3c9b2c1"). It re-compresses the string by combining multiple occurrences of the same character and their counts, resulting in a more efficient representation (e.g., "a3b2c10"). """
def betterCompression(s): # ... (rest of the function code is the same as before) */
Explanation of the descriptions:
- minimum_flips.py:
- Title: Clearly states the problem the script solves.
- Description: Explains the concept of bit flips and provides a simple example to illustrate the calculation.
- better_compression.py:
- Title: Describes the purpose of the script - optimizing string compression.
- Description: Briefly explains the input format (characters followed by frequencies) and how the script improves the compression.
Key Improvements:
- Clarity: The titles and descriptions make it immediately clear what each script does, even for someone unfamiliar with the code.
- Documentation: These descriptions serve as valuable documentation for future reference or for other developers who may use your code.
- Readability: The code files are now more reader-friendly, making them easier to understand and maintain.
Additional Considerations:
- You can include the installation instructions for
pypdf2
andpandas
if this project is part of a larger repository that requires these libraries. - Consider adding examples of how to run the scripts and their expected outputs in the descriptions to further enhance their usefulness.
*/
Explicação detalhada dos códigos:
- Pandas:
A biblioteca pandas é utilizada para carregar e manipular DataFrames em Python. A função read_excel() carrega o conteúdo do arquivo Excel em um DataFrame. A coluna C é acessada usando o nome da coluna ("C") ou o índice (2). A função dropna() remove as células vazias da coluna C. Um loop for itera sobre cada valor da coluna C. 2. NumPy:
A biblioteca numpy é utilizada para trabalhar com arrays em Python. A função loadtxt() carrega o conteúdo do arquivo Excel em um array NumPy. A coluna C é acessada usando a indexação de array (coluna 2). Um loop for itera sobre cada valor da coluna C. A condição if valor != '' verifica se a célula não está vazia. 3. Openpyxl:
A biblioteca openpyxl é utilizada para ler e manipular arquivos Excel em Python. A função load_workbook() carrega o conteúdo do arquivo Excel em um objeto Workbook. A planilha ativa é acessada usando a propriedade active. A coluna C é acessada usando a notação de célula ('C'). Um loop for itera sobre cada célula da coluna C, ignorando a primeira linha (cabeçalho). A condição if cell.value is not None verifica se a célula não está vazia. Observações:
Adapte os nomes das variáveis e arquivos de acordo com o seu projeto. Você pode modificar o código para realizar outras operações nas células, como formatar texto, adicionar comentários ou realizar cálculos. Consulte a documentação das bibliotecas para obter mais informações sobre suas funcionalidades. Recursos adicionais:
- Documentação Pandas: https://pandas.pydata.org/
- Documentação NumPy: https://numpy.org/
- Documentação Openpyxl: https://openpyxl.readthedocs.io/
Script para baixar imagens do WhatsApp e criar pastas no Google Drive
Script for download images from whatsapp and create folders at Google Drive
a code to count squirrels by conclusion of some code aspects variations, also creating dataframes and making conversion of fahrenheit temperature