1234567891011121314151617 |
- import os
- from pathlib import Path
- def create_headerfiles(base_dir: str):
- """opens every *.csv in base_dir and saves first line to subfolder "Kopfzeilen" """
- dest = Path(f"{base_dir}\\Kopfzeilen")
- os.makedirs(dest, exist_ok=True)
- for source_file in Path(base_dir).glob("*.csv"):
- dest_file = dest / source_file.name
- with source_file.open("r", encoding="latin-1") as frh, dest_file.open("w", encoding="latin-1") as fwh:
- fwh.write(frh.readline())
- if __name__ == "__main__":
- create_headerfiles("C:/GlobalCube/System/OPTIMA/Export")
|