Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

📦 Data Unit Converter

A Python utility function for converting data sizes between different units — bits, bytes, kilobytes, megabytes, gigabytes, and beyond.


✨ Features

  • Convert between bit-scale units: b, kb, mb, gb, tb, pb, eb
  • Convert between byte-scale units: B, KB, MB, GB, TB, PB, EB
  • Smart auto-scaling — automatically selects the most readable unit based on size
  • Explicit target conversion — specify exactly which unit to convert to
  • Handles floating-point precision with rounding

🖥️ Tech Stack

Category Technology
Language Python 3
Type Pure function (no dependencies)

🚀 Usage

from DataConverter import convert

# Convert to a specific unit
print(convert(size="1024 MB", convert_to="GB"))   # → "1.0 GB"
print(convert(size="500 b", convert_to="KB"))     # → "0.0610 KB"

# Auto-scale to human-readable size
print(convert(size="1048576 KB", mode="Bytes"))   # → "1.0 GB"

📝 What I Learned

  • Handling complex keyword argument patterns (**kwargs)
  • Unit conversion math with powers of 1024
  • Writing reusable, importable utility functions
  • The difference between bit-based and byte-based data units

Made with ❤️ as part of a learning journey