wip 2.0
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
example
|
||||
example-csv
|
||||
.venv
|
||||
*.egg-info
|
||||
__pycache__
|
||||
example
|
||||
65
BudaportaFvmConvert/__init__.py
Normal file
65
BudaportaFvmConvert/__init__.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# import xml.etree.ElementTree as ET
|
||||
# import xmlformatter
|
||||
import argparse
|
||||
from importlib.metadata import metadata
|
||||
from pathlib import Path
|
||||
import csv
|
||||
|
||||
REQUIRED_CSV_COLUMNS = ['Notes', 'Meter n°', 'Reading', 'Reading data']
|
||||
|
||||
|
||||
METADATA = metadata("BudaportaFvmConvert")
|
||||
__version__ = METADATA["Version"]
|
||||
|
||||
def run():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=METADATA["Name"],
|
||||
description=METADATA["Summary"],
|
||||
)
|
||||
|
||||
parser.add_argument("-v", "--version",
|
||||
action="version",
|
||||
version=f'{METADATA["Name"]} {METADATA["Version"]}'
|
||||
)
|
||||
|
||||
parser.add_argument("source",
|
||||
type=Path,
|
||||
help="Path to a csv file or a folder",
|
||||
nargs="+"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
csvpaths = []
|
||||
|
||||
for path in args.source:
|
||||
if path.is_dir():
|
||||
csvpaths.extend(get_csv_paths(path))
|
||||
elif path.suffix == ".csv":
|
||||
csvpaths.append(path)
|
||||
|
||||
for csvpath in csvpaths:
|
||||
CsvFile(csvpath)
|
||||
|
||||
|
||||
|
||||
def get_csv_paths(dp: Path):
|
||||
paths = []
|
||||
if dp.is_dir():
|
||||
for p in dp.iterdir():
|
||||
if p.suffix == ".csv":
|
||||
paths.append(p)
|
||||
return paths
|
||||
|
||||
|
||||
class CsvFile:
|
||||
def __init__(self, filepath: Path) -> None:
|
||||
with open(filepath, newline='') as csvfile:
|
||||
incsv = csv.reader(csvfile, delimiter=';')
|
||||
# csvArrs.append([])
|
||||
# for row in incsv:
|
||||
# csvArrs[0].append(row)
|
||||
|
||||
class CsvRow:
|
||||
def __init__(self, ) -> None:
|
||||
pass
|
||||
4
BudaportaFvmConvert/__main__.py
Normal file
4
BudaportaFvmConvert/__main__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from BudaportaFvmConvert import run
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
17
README.md
17
README.md
@@ -2,6 +2,16 @@
|
||||
|
||||
Vízműveknek megfelelő xml konvertálása leolvasó programból kijövő csv fájlból.
|
||||
|
||||
## Telepítés
|
||||
|
||||
### Python-venv virtuális környezetben
|
||||
|
||||
```shell
|
||||
python -m venv .venv
|
||||
. ./.venv/bin/activate
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
## Adatok megfeleltetése
|
||||
|
||||
| Fix érték | csv | xml |
|
||||
@@ -26,9 +36,10 @@ Egy xml fájl neve hossza legfeljebb 40 karakter lehet!
|
||||
A file nevében ne legyen ékezetes karakter.
|
||||
Egy sor sem lehet 50 karakternél hosszabb!
|
||||
|
||||
## Példa
|
||||
|
||||
## Telepítés
|
||||
Szerveren itt, linux útvonal:
|
||||
|
||||
```shell
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
smb://bdc1.boffice.local/porta/Társasházkezelés/DOKUMENTUMTÁR/_VÍZ_ELSZÁMOLÁS_/ZSOLT%20UDVAR/Gépi%20kiolvasás%202020.12.03.tól/
|
||||
```
|
||||
33
pyproject.toml
Normal file
33
pyproject.toml
Normal file
@@ -0,0 +1,33 @@
|
||||
[project]
|
||||
name = "BudaportaFvmConvert"
|
||||
version = "2.0.0"
|
||||
description = "Convert meter readings from CSV to XML"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
license = {file = "LICENSE"}
|
||||
authors = [
|
||||
{name = "infeeeee", email = "gyetpet@mailbox.org"}
|
||||
]
|
||||
maintainers = [
|
||||
{name = "infeeeee", email = "gyetpet@mailbox.org"}
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Programming Language :: Python",
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
"xmlformatter"
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
homepage = "https://git.gyetvaipeter.hu/infeeeee/BudaportaFvmConvert"
|
||||
documentation = "https://git.gyetvaipeter.hu/infeeeee/BudaportaFvmConvert"
|
||||
repository = "https://git.gyetvaipeter.hu/infeeeee/BudaportaFvmConvert"
|
||||
changelog = "https://git.gyetvaipeter.hu/infeeeee/BudaportaFvmConvert"
|
||||
|
||||
[project.scripts]
|
||||
BudaportaFvmConvert = "BudaportaFvmConvert:run"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
@@ -1 +0,0 @@
|
||||
xmlformatter
|
||||
Reference in New Issue
Block a user