Skip to main content

Sort description

Project description

Infra Analytics

Package Python để xử lý và phân tích dữ liệu hạ tầng, đặc biệt tập trung vào dữ liệu phường xã Việt Nam.

Tính năng

  • Crawl và xử lý thông tin phường xã từ Wikipedia
  • Làm sạch và chuẩn hóa văn bản tiếng Việt
  • Lưu trữ và quản lý dữ liệu trong PostgreSQL
  • Xử lý dữ liệu đa luồng để tăng hiệu suất

Cài đặt

Cài đặt từ PyPI

pip install infra-analytics

Sử dụng

Sử dụng trong code Python

from infra_analytics.crawler import process_ward_data
from infra_analytics.database import get_db_connection

# Xử lý dữ liệu phường xã
process_ward_data()

# Hoặc xử lý với kết nối DB tùy chỉnh
conn = get_db_connection()
process_ward_data(conn)

Sử dụng Command Line

# Chạy crawler
infra-crawler

# Chạy với cấu hình tùy chỉnh
infra-crawler --config path/to/config.yaml

Ví dụ xử lý dữ liệu

from infra_analytics.utils import clean_ward_name, get_province_short
from infra_analytics.database import upsert_ward_info

# Chuẩn hóa tên phường
ward_name = clean_ward_name("Phường 1, Quận 1")
print(ward_name)  # Output: Phường 1

# Lấy tên tỉnh ngắn gọn
province = get_province_short("Thành phố Hồ Chí Minh")
print(province)  # Output: Hồ Chí Minh

# Cập nhật thông tin phường
ward_data = (12345, "Phường 1", "Phường", "Quận 1", "Hồ Chí Minh", 10000, 2.5, 4000, "https://wikipedia.org/...")
upsert_ward_info(conn, ward_data)

Cấu trúc Project

infra_analytics/
├── __init__.py
├── config.py          # Cấu hình
├── crawler.py         # Module crawler chính
├── database.py        # Xử lý database
└── utils.py          # Các hàm tiện ích

Yêu cầu hệ thống

  • Python >= 3.8
  • PostgreSQL >= 12
  • Đủ quyền truy cập database
  • Kết nối internet để crawl Wikipedia

Xử lý lỗi thường gặp

  1. Lỗi kết nối database:

    • Kiểm tra thông tin kết nối trong file .env
    • Đảm bảo PostgreSQL đang chạy
    • Kiểm tra quyền truy cập
  2. Lỗi crawl Wikipedia:

    • Kiểm tra kết nối internet
    • Đảm bảo URL Wikipedia hợp lệ
    • Thử lại sau nếu bị rate limit
  3. Lỗi xử lý dữ liệu:

    • Kiểm tra định dạng file Excel
    • Đảm bảo encoding UTF-8
    • Kiểm tra dữ liệu đầu vào

License

Project này được cấp phép theo MIT License - xem file LICENSE để biết thêm chi tiết.

Author: Hautx2.fpt.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infra_analytics-0.1.4.tar.gz (93.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

infra_analytics-0.1.4-py3-none-any.whl (102.3 kB view details)

Uploaded Python 3

File details

Details for the file infra_analytics-0.1.4.tar.gz.

File metadata

  • Download URL: infra_analytics-0.1.4.tar.gz
  • Upload date:
  • Size: 93.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for infra_analytics-0.1.4.tar.gz
Algorithm Hash digest
SHA256 edad0136cf03b56236c71c1b4ad9bdef86623c901e07b585a79f757c8fe251d6
MD5 c00964c92edda1d8f9e8eddaa84b8540
BLAKE2b-256 0f93ae1275aadb4f7493238b0bfdffd78f577075993f9331d826cd1bc9fb15de

See more details on using hashes here.

File details

Details for the file infra_analytics-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: infra_analytics-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 102.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for infra_analytics-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a628586b497eafa39fecee72b77bd0ed39438f52f7a927cce3874f1a11778b90
MD5 7f0bd8e8c7c7997021de466b2e2653c6
BLAKE2b-256 8851e189242e9072911291807e3cf30bf6977ee29066d8d0000037bbdde3bea3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page