ExcelCSVParseHelper
A lightweight Python library to help parse, manipulate, and automate workflows between CSV and Excel files.
Features
- Insert numerical or string data into Excel cells
- Automatically reopen or close Excel files (Windows platform, other OS best-effort with manual fallback)
- Parse, clean, and filter CSV datasets
- Read ranges from Excel sheets
- Split lists into positives/negatives for further processing
Installation
pip install ExcelCSVParseHelper
On Windows, psutil and pywin32 are installed automatically (via environment markers) and enable the Excel process-close helper. The reopen helper is best-effort and works cross-platform.
On macOS/Linux, core CSV/Excel parsing and writing functions work normally; the Excel process close helper is disabled and will instruct you to close the workbook manually if needed. The reopen helper will try to launch your default application (best-effort).
Included dependency
As of v1.2.2, this package installs LockFileSemaphore automatically as a dependency (no separate installation required).
You can import and use it directly:
from LockFileSemaphore import FileLock
with FileLock("/tmp/my.lock"):
# protected section
pass
Example Usage
from ExcelCSVParseHelper import *
insert_data_to_excel("myfile.xlsx", {"A1": 100, "B2": 200}, sheet_arg="Sheet1")
df = prepare_source(base_path="data.csv", sep=",", columns_to_drop=[0, 2])
More advanced use cases are also supported like for example via use of a 'staging' function in the following manner:
def run(
date,
idea1_base_path,
idea1_postfix = "_results_ide1.csv",
idea1_sep = ";",
ida1_columns_to_keep = [1, 2],
idea1_prefix_list = ["A", "B"],
idea1_column_list = ["One", "Two"],
idea1_start_int= 1,
idea1_include_header= True,
raw_path = None
):
postfix= idea1_postfix
base_path= idea1_base_path
sep= idea1_sep
columns_to_keep= ida1_columns_to_keep
return_dict= {}
prefix_list= ida1_prefix_list
column_list= ida1_column_list
for i in range(len(prefix_list)):
return_dict = set_source(
file_path= raw_path,
prefix_letter=prefix_list[i],
column_target=column_list[i],
date_target=f"{date}",
start_int= idea1_start_int,
header=column_list[i],
postfix=postfix,
base_path=base_path,
sep=sep,
white_list=True,
columns_to_keep=columns_to_keep,
infer=False,
header_start= 213,
range_of_interest_start=0,
range_of_interest_end=96,
include_header= idea1_include_header
)
fp = return_dict["file_path"]
close_excel_file_if_open(return_dict["file_path"])
insert_data_to_excel(
return_dict["file_path"],
return_dict["column_insert"],
sheet_arg= "data",
)
or
def run_2(
date,
two_base_path,
two_colums_to_drop=[
"UsrName",
"TmZn",
"INFO",
"Self",
],
two_postfix="-two.csv",
two_sep=";",
two_prefix_list=["B", "C", "D", "E", "F"], #do których kolumn będzie wstawione
two_column_list=["1", "2" , "3", "4", "5"],
two_start_int= 1,
two_include_header= True,
raw_path = None
):
postfix = two_postfix
base_path= two_base_path
sep = two_sep
columns_to_drop = two_colums_to_drop
return_dict = {}
prefix_list = two_prefix_list
column_list = two_column_list
for i in range(len(prefix_list)):
return_dict = set_source(
file_path= raw_path,
prefix_letter=prefix_list[i],
column_target=column_list[i],
date_target=f"{date}",
start_int= two_start_int,
header=column_list[i],
postfix=postfix,
base_path=base_path,
sep=sep,
columns_to_drop=columns_to_drop,
white_list=False,
columns_to_keep=None,
infer=True,
header_start=None,
range_of_interest_start=None,
range_of_interest_end=None,
include_header= two_include_header
)
fp = return_dict["file_path"]
close_excel_file_if_open(return_dict["file_path"])
insert_data_to_excel(
return_dict["file_path"],
return_dict["column_insert"],
sheet_arg= "Dane",
)
Metadata
Release files for ExcelCSVParseHelper 1.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| excelcsvparsehelper-1.2.3.tar.gz | 9.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| excelcsvparsehelper-1.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / excelcsvparsehelper-1.2.3.tar.gz
| Download URL | excelcsvparsehelper-1.2.3.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2028e3bd661cf085fde7d88bb95d67ab88f96893295d51cbbfbca008c6d9c027
|
|
BLAKE2b-256 checksum How to use checksums |
4ffefcb4b6f5ddf15e697e6ed55dbe911fc16072a09cffe807e402f5e2d79a4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / excelcsvparsehelper-1.2.3-py3-none-any.whl
| Download URL | excelcsvparsehelper-1.2.3-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f35778014a7019b17692f1efb43908ce12dd9407aab6d9261bd3c687a0af121
|
|
BLAKE2b-256 checksum How to use checksums |
77b99afa77d0759afebdf0e0e3a4e6ceca3bf1e5b7848eb8ca5e318aa2cd60d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|