Spaces:
Running
Running
Andre
deploy: snapshot c96b9ab -- Inventory Journals (Lagerforandringsjournal) na Contabilidade (v1.3.61)
77db408 Download backend/scripts/check_headers_v3.py from inwave-gateway/hub: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/inwave-gateway/hub/resolve/main/backend/scripts/check_headers_v3.py
- Command line
-
hf download hf://spaces/inwave-gateway/hub/backend/scripts/check_headers_v3.py
-
curl -L -o check_headers_v3.py https://huggingface.co/spaces/inwave-gateway/hub/resolve/main/backend/scripts/check_headers_v3.py
1.24 kB
| import os | |
| import csv | |
| from io import StringIO | |
| def _auto_decode(content: bytes) -> str: | |
| if not content: return "" | |
| # Explicitly try latin-1 if it looks like Visma export (common in Nordics) | |
| if content.startswith(b'\xef\xbb\xbf'): | |
| return content.decode('utf-8-sig') | |
| try: | |
| return content.decode('utf-8') | |
| except: | |
| try: | |
| return content.decode('latin-1') | |
| except: | |
| return content.decode('cp1252', errors='replace') | |
| assets_dir = r"backend/assets" | |
| output = "" | |
| for filename in sorted(os.listdir(assets_dir)): | |
| if filename.endswith(".csv"): | |
| path = os.path.join(assets_dir, filename) | |
| with open(path, 'rb') as f: | |
| content = f.read(4096) | |
| text = _auto_decode(content) | |
| first_line = text.split('\n')[0].strip() | |
| # Clean up potential BOM or weird start | |
| if first_line.startswith('\ufeff'): first_line = first_line[1:] | |
| headers = [h.strip().strip('"') for h in first_line.split(';')] | |
| output += f"File: {filename}\nHeaders: {', '.join(headers)}\n" | |
| output += "-" * 40 + "\n" | |
| with open("backend/headers_report.txt", "w", encoding="utf-8") as f: | |
| f.write(output) | |
| print("Done") | |