File worker
User Guide
- Copy folder, change each file extension and paste folder
import shutil
import fileworker as fw
SOURCE_FOLDER_PATH = "data/test"
TARGET_FOLDER_PATH = "data/test_csv"
FILE_FORMAT = ".csv"
# Class for managing file paths
path_manager = fw.PathManager()
# Get a list of source paths
source_paths = path_manager.get_source_paths(SOURCE_FOLDER_PATH)
print("Source paths:", source_paths)
print("Number of source paths:", len(source_paths))
# Get a list of target paths with the ".csv" extension
target_paths = path_manager.get_target_paths(TARGET_FOLDER_PATH, FILE_FORMAT)
print("Target paths:", target_paths)
print("Number of target paths:", len(target_paths))
# Get a list of missing folder paths
target_missing_folder_paths = path_manager.get_target_folder_paths(skip_existing=True)
print("Target missing folder paths:", target_missing_folder_paths )
# Create missing folders
path_manager.create_missing_folders()
# Get a list of pairs of source and target files, skipping existing ones
path_pairs = path_manager.get_file_pairs(skip_existing=True)
print("List of source and target file pairs:", path_pairs)
for source_path, target_path in path_pairs:
print("Copying:", source_path, "->", target_path)
try:
shutil.copy(source_path, target_path)
except shutil.SameFileError:
print("Source and destination represents the same file.")
except PermissionError:
print("Permission denied.")
except:
print("Error occurred while copying file.")
Metadata
Release files for fileworker 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fileworker-0.1.0.tar.gz | 1.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fileworker-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.2 kB
Release files / fileworker-0.1.0.tar.gz
| Download URL | fileworker-0.1.0.tar.gz |
|---|---|
| Size | 1.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b19a0f222063422ea84bb14533ffff48bb66e0c16290fbbc1d4423534fb6a38
|
|
BLAKE2b-256 checksum How to use checksums |
a624659ceea2a11a2314f6ef16b63383e13c1aeea0accf195d5fcb3afe0b7002
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-32-generic
|
Release files / fileworker-0.1.0-py3-none-any.whl
| Download URL | fileworker-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fae4ca2b73cc7b2a0e5c6fad866ef0fb3ef7d97f740433870b25453ce8ea111b
|
|
BLAKE2b-256 checksum How to use checksums |
965ac7fd2837d01ff9bf676008c48b32c4adfccab2a4f8ec5149c2e72da9fb2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-32-generic
|