A package that assist with imports via drag and dropping of files so end users can run scripts with ease
Project description
Script that contains utility definitions common to most import scripts
Author: Alok M Date: 11/2015 Packaged by: Devin Akerley Date: 06/2024
This script contains some common function definitions that are needed by most python file import scripts. The goal of this script is to reduce the amount of coding required to generate a new file import script.
The anticipated usage is as follows:
-
include a line at the top of a specific script as follows:
from fileimport_util import *
-
Define specific functions to read an instrument file and write a corresponding clims file.
def read_file(filename): ...
def write_file(filename): ...
In both function definitions, the "filename" corresponds to the fully specified filename that the user has selected. If the user selects multiple files, these functions will be called once for each file. In these, if something goes wrong, the function should raise an exception; any data that needs to be communicated between these should be managed through global variables. Some commonly used filename parsing functions are imported:
-
Call the main function to kick off the processing
transform(read_file, write_file)
What you get from this file: - pre-imports of commonly used python modules - pre-imports of specific useful components of modules: - pprint() - OrderedDict() - dirname() Example: dirname("a/b/c/a.csv") => "a/b/c" - basename() Example: basename("a/b/c/a.csv") => "a.csv" - splitext() Example: file_part, extension = splitext("a/b/c/a.csv") => ("a/b/c/a", ".csv") - get_input_filenames: provides support to prompt user for filenames; - main(): supports drag/drop of files onto script; if none are provided, then prompts user; then alternates between calling read_file and write_file to process each. - Logger (LOG), useful for logging errors and warnings.
Change Log: AKM 11/2015: Created.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fileimport_util-1.0.tar.gz.
File metadata
- Download URL: fileimport_util-1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a1f6c42001db996d2f1e58bce382593405f97415eadda54a848a28ee67e3121
|
|
| MD5 |
c3b384355a81c96fa28936fd699f51a7
|
|
| BLAKE2b-256 |
ec11cf886b7162dacd9f626a32e79b2da538689201b1b2425add5b73b1ca3d56
|
File details
Details for the file fileimport_util-1.0-py3-none-any.whl.
File metadata
- Download URL: fileimport_util-1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
768c18cfabbd53d858da509b2bc4ac491fd09b32a30b317ce249d2fe84d6f12c
|
|
| MD5 |
3eb44a948648c8234f7599382fb70d1e
|
|
| BLAKE2b-256 |
5225657027695068d23c97d629778d5c64cfd774aeb3739c40193b5b8f628aec
|