Skip to main content

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 --force flag to add BOM to files with other encodings

License

MIT License - See LICENSE file for details

Release files for add-bom 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for add-bom 1.0.0
File Size Uploaded
add_bom-1.0.0.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for add-bom 1.0.0
File Interpreter ABI Platform
add_bom-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 kB

Release files / add_bom-1.0.0.tar.gz

Download URL add_bom-1.0.0.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
03d5d702624c0779b0ad952b9ee9eaf509d91811a2de7a3fceca8a5491bbe648
BLAKE2b-256 checksum
How to use checksums
a0e01ef6cebf0ec264ed4555f0e586578e55d9b42bea160feae045ead294f628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.10.6 Darwin/24.4.0

Release files / add_bom-1.0.0-py3-none-any.whl

Download URL add_bom-1.0.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d95e2f43269fbf1ff0acdb0b9f6741805730a63d54a90e991651544f8b71ab2e
BLAKE2b-256 checksum
How to use checksums
7bfa1850fead751c5f46c71fc66a537e6e3b9d57430ef00927ee9c956d34a2b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.10.6 Darwin/24.4.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page