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
-
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
-
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
-
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file infra_analytics-0.0.8.tar.gz.
File metadata
- Download URL: infra_analytics-0.0.8.tar.gz
- Upload date:
- Size: 94.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de4ec35406ed6f6500d9e0842f394db0e81aad7f6457f7d2bee4e9206e96c920
|
|
| MD5 |
9bcbcdd51c4525951031f9541898f9fd
|
|
| BLAKE2b-256 |
9efb6041ee85af3058e964f1511699051552a5658730b355180eeb10c079c373
|
File details
Details for the file infra_analytics-0.0.8-py3-none-any.whl.
File metadata
- Download URL: infra_analytics-0.0.8-py3-none-any.whl
- Upload date:
- Size: 104.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e4d3fd4b9cdb5c23a9bf79703f4af7d942e0dbc083d23473218de06832af625
|
|
| MD5 |
d9532eb7c9d07c7117f2e90326cd130e
|
|
| BLAKE2b-256 |
8886ccc46300ee6a7ad8ef846777375f465c12099e99fc91e543a951671027b4
|