2023-10-29 17:09:54 +03:00

96 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Lenenergo parser
## Описание
Библиотека, куда собран код, необходимый для получения, обработки и сохранения данных с сайта [Россети Ленэнерго](https://rosseti-lenenergo.ru/planned_work/)
## Интерфейс
- `LenenergoParser`:
```python
class LenenergoParser:
def __init__(self, ndays=7, today: Optional[datetime] = None, file_path: Optional[str] = None) -> None
self.base_url: str
self.ndays: int
self.today: datetime
self.df: pd.DataFrame
def __str__(self) -> str
def fetch(self, ndays: Optional[int] = None, today: Optional[datetime] = None) -> None
def save_df(self, file_path: str) -> None
def load_df(self, file_path: str) -> None
```
- `split_addresses`:
```python
def split_addresses(df: pd.DataFrame) -> pd.DataFrame
```
- `get_building_id`:
```python
def get_building_id(street: str) -> GeoTupleType
```
- `fetch_builing_ids`:
```python
def fetch_builing_ids(df: pd.DataFrame) -> pd.DataFrame
```
- `async_fetch_building_id`:
```python
async def async_fetch_building_id(
session: aiohttp.ClientSession, street: str
) -> GeoTupleType
```
- `async_fetch_building_ids`:
```python
async def async_fetch_building_ids(df: pd.DataFrame) -> pd.DataFrame
```
- `concurrent_fetch_builing_ids`:
```python
def concurrent_fetch_builing_ids(df: pd.Dataframe) -> pd.DataFrame
```
- `preprocess_df`:
```python
def preprocess_df(df: pd.DataFrame) -> pd.DataFrame
```
- `COL_NS`:
```python
COL_NS: dict[str, str]
```
- `ICOL_NS`:
```python
ICOL_NS: dict[str, str]
```
- `PR_COL_NS`:
```python
PR_COL_NS: tuple[str]
```
- `preprocess_read_df`:
```python
def preprocess_read_df(df: pd.DataFrame) -> pd.DataFrame
```
- `group_by_index`:
```python
def group_by_index(df: pd.DataFrame) -> pd.DataFrame
```
- `pipeline`:
```python
def pipeline(parser: Optional[LenenergoParser] = None) -> LenenergoParser
```
## Инструкция по запуску
В корневой папке проекта:
```bash
python -m venv .venv
pip install -r requirements.txt
python -m parser [<Период в часах>]
```
Формат сохраняемых файлов: `data_%d-%m-%y_%H.%M.csv`