feat(csv_import): Enhance CSV import functionality with new endpoint and parsing improvements
- Updated version for csv_import to 0.2.0, reflecting new features. - Implemented a new POST endpoint for universal CSV import, supporting nutrition, weight, and blood pressure modules. - Added CSV parsing function to yield rows as dictionaries for easier data handling. - Enhanced error handling and logging for import operations. - Introduced tests for the new CSV parsing functionality to ensure reliability.
This commit is contained in:
1 parent
36417bfdf3
commit
851018b3b9
6 files changed
+637
-4
No files matched your search
@@ -9,6 +9,7 @@ from csv_parser.core import (
|
||||
column_signature,
|
||||
headers_signature_match_score,
|
||||
get_csv_import_limits,
|
||||
iter_csv_dict_rows,
|
||||
)
|
||||
from csv_parser.type_converter import convert_value, build_row_after_mapping
|
||||
|
||||
@@ -57,6 +58,12 @@ def test_convert_date_and_kcal_factor():
|
||||
assert abs(k - 8000 * 0.239) < 0.01
|
||||
|
||||
|
||||
def test_iter_csv_dict_rows_full_file():
|
||||
text = "a;b\n1;2\n3;4\n"
|
||||
rows = list(iter_csv_dict_rows(text, ";", has_header=True))
|
||||
assert rows == [{"a": "1", "b": "2"}, {"a": "3", "b": "4"}]
|
||||
|
||||
|
||||
def test_build_row_after_mapping():
|
||||
csv_row = {"Datum": "01.01.2024", "kj": "4200"}
|
||||
fm = {"Datum": "date", "kj": "kcal"}
|
||||
|
||||
Reference in new issue
Block a user