A simple utility to add a BOM to a file to ensure it opens as UTF-8 in Excel on a Mac
Project description
add-bom
A simple command-line utility to add a UTF-8 BOM (Byte Order Mark) to files. This is particularly useful for CSV files that need to be opened correctly in Excel on macOS, where files without a BOM might be interpreted with incorrect character encoding.
Installation
The recommended way to install this tool is using pipx:
pipx install add-bom
Usage
add-bom <file>
Options
--force: Force add BOM to file regardless of current encoding
Examples
Add BOM to a UTF-8 CSV file:
add-bom data.csv
Force add BOM to a file (use with caution):
add-bom data.csv --force
What is a BOM?
A BOM (Byte Order Mark) is a special character sequence at the beginning of a text file that indicates the encoding of the file. For UTF-8 files, the BOM is the sequence EF BB BF in hexadecimal.
Why is this needed?
When opening CSV files in Excel on macOS, files without a BOM might be interpreted with incorrect character encoding (like MacRoman or Windows-1252), leading to garbled text. Adding a UTF-8 BOM ensures that Excel correctly recognizes the file as UTF-8 encoded.
Safety Features
The tool includes several safety checks:
- Verifies the file exists
- Checks if the file already has a BOM
- By default, only adds BOM to files that are already UTF-8 encoded
- Requires
--forceflag to add BOM to files with other encodings
License
MIT License - See LICENSE file for details
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 add_bom-1.0.0.tar.gz.
File metadata
- Download URL: add_bom-1.0.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.6 Darwin/24.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03d5d702624c0779b0ad952b9ee9eaf509d91811a2de7a3fceca8a5491bbe648
|
|
| MD5 |
d20cc7493488ea2457e0236d55c55599
|
|
| BLAKE2b-256 |
a0e01ef6cebf0ec264ed4555f0e586578e55d9b42bea160feae045ead294f628
|
File details
Details for the file add_bom-1.0.0-py3-none-any.whl.
File metadata
- Download URL: add_bom-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.6 Darwin/24.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d95e2f43269fbf1ff0acdb0b9f6741805730a63d54a90e991651544f8b71ab2e
|
|
| MD5 |
05cc88a4eb5810068ab1f27fdd4f3304
|
|
| BLAKE2b-256 |
7bfa1850fead751c5f46c71fc66a537e6e3b9d57430ef00927ee9c956d34a2b8
|