You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

硕士论文求助:将宣传册PDF转指定结构Excel表格(工具无效)

解决宣传册PDF转结构化Excel表格的方案

Hey there! Converting that Netto brochure into a structured Excel table (with Productname/NormalPrice/DiscountPrice/Size/Unit columns) for your master's thesis sounds tricky—those generic PDF conversion tools often struggle with promotional layouts that mix text, images, and crossed-out prices. Let me share a few practical approaches that should work better:

方法1:Python + OCR 自动化提取(适合有编程基础)

This approach gives you full control over data extraction, perfect for handling the brochure's specific layout. Here's how to do it:

  • Step 1: Setup dependencies
    Install required packages via pip:

    pip install pdf2image pytesseract pandas pillow
    

    You'll also need to install the Tesseract OCR engine (from its official distribution) and download the German language pack to ensure accurate recognition of the brochure's text.

  • Step 2: Extract and process text
    Use this code snippet to convert PDF pages to images, run OCR, and extract structured data:

    import pdf2image
    import pytesseract
    import pandas as pd
    import re
    
    # Configure Tesseract path (adjust to match your installation location)
    pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
    
    # Convert PDF pages to image files
    pages = pdf2image.convert_from_path("hz19_cosf.pdf")
    
    # Initialize list to store cleaned product data
    product_data = []
    
    for page in pages:
        # Extract text from the page with German language support
        page_text = pytesseract.image_to_string(page, lang='deu')
        
        # Regex pattern to match product entries (adjust based on brochure's actual layout)
        # This targets product names, crossed-out normal prices, discount prices, and size/unit
        product_matches = re.findall(
            r"(.*?)\s+(\d+,\d+€)\s+\(?\d+,\d+€\)?|\s+(\d+[gml])",
            page_text,
            re.DOTALL
        )
        
        for match in product_matches:
            # Clean up and map extracted values to columns
            product_name = match[0].strip() if match[0] else ""
            discount_price = match[1] if match[1] else ""
            normal_price = match[2] if match[2] else ""
            size_unit = match[3] if match[3] else ""
            
            if size_unit:
                size = size_unit[:-1]
                unit = size_unit[-1:]
            else:
                size = ""
                unit = ""
            
            product_data.append({
                "Productname": product_name,
                "NormalPrice": normal_price,
                "DiscountPrice": discount_price,
                "Size": size,
                "Unit": unit
            })
    
    # Export the structured data to Excel
    df = pd.DataFrame(product_data)
    df.to_excel("netto_products.xlsx", index=False)
    

    Note: You’ll likely need to tweak the regex pattern to perfectly match the brochure’s exact formatting—check a few pages of OCR-extracted text to adjust the matching rules for prices and product names.

方法2:专业OCR工具手动修正(适合非编程用户)

If coding isn’t your thing, use tools built for structured document extraction:

  • Adobe Acrobat Pro: Use its "Form Recognition" feature to auto-detect table-like structures in the PDF. You can manually correct any misidentified fields (like mixed-up prices or truncated product names) before exporting directly to Excel.
  • Google Document AI: Upload the PDF to Google’s Document AI service (requires a free Cloud account with limited free usage). It specializes in extracting structured data from complex promotional documents, and you can export the results as a CSV or Excel file.

方法3:手动+Excel批量处理(适合少量页数)

If the brochure isn’t too long, this low-tech approach can be surprisingly efficient:

  1. Take clear screenshots of each page, then use a free online OCR tool to extract raw text from each image.
  2. Paste all extracted text into an Excel sheet, then use Excel’s Text to Columns feature to split content by spaces or custom delimiters.
  3. Use Excel’s built-in functions to clean up data:
    • Use FILTER to isolate crossed-out prices and map them to the NormalPrice column
    • Match current promotional prices to DiscountPrice
    • Use LEFT() and RIGHT() functions to split entries like "500g" into Size (500) and Unit (g)

内容的提问来源于stack exchange,提问作者Anski100

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:54:16