Below is a Python script that generates realistic fake product data using the faker library. This data includes product names, categories, prices, descriptions, and other attributes commonly found in e-commerce platforms.
Generated Fake Product Data Example:
| Product ID | Product Name | Category | Price | Stock | Rating | Description |
|---|---|---|---|---|---|---|
| 1 | Organic Green Tea | Beverages | 99 | 150 | 5 | Premium loose-leaf green tea with a smooth, earthy flavor. Rich in antioxidants. |
| 2 | Wireless Bluetooth Earbuds | Electronics | 99 | 75 | 2 | High-quality sound with 8-hour battery life. Includes charging case. |
| 3 | Artisan Dark Chocolate | Food & Snacks | 50 | 60 | 8 | Single-origin cocoa beans with 85% cocoa content. Handcrafted in Belgium. |
| 4 | Cotton Yoga Pants | Clothing | 99 | 200 | 6 | Ultra-soft, breathable fabric. Perfect for yoga, workouts, or casual wear. |
| 5 | Stainless Steel Water Bottle | Home & Kitchen | 99 | 120 | 3 | Double-wall insulation keeps drinks cold for 24h or hot for 12h. BPA-free. |
Python Script to Generate Fake Product Data:
from faker import Faker
import random
fake = Faker()
# Define categories and attributes
categories = [
"Electronics", "Clothing", "Home & Kitchen", "Food & Snacks",
"Beverages", "Beauty", "Sports", "Books", "Toys", "Automotive"
]
# Generate 10 fake products
products = []
for i in range(1, 11):
product = {
"Product ID": i,
"Product Name": fake.catch_phrase(),
"Category": random.choice(categories),
"Price": round(random.uniform(5.99, 199.99), 2),
"Stock": random.randint(10, 500),
"Rating": round(random.uniform(3.5, 5.0), 1),
"Description": fake.paragraph(nb_sentences=3)
}
products.append(product)
# Print the generated data
for product in products:
print(f"Product ID: {product['Product ID']}")
print(f"Product Name: {product['Product Name']}")
print(f"Category: {product['Category']}")
print(f"Price: ${product['Price']}")
print(f"Stock: {product['Stock']}")
print(f"Rating: {product['Rating']}/5.0")
print(f"Description: {product['Description']}")
print("-" * 50)
Key Features:
- Realistic Data: Uses
Fakerto generate believable product names, descriptions, and categories. - Diverse Categories: Includes 10 common e-commerce categories.
- Dynamic Attributes:
- Prices range from $5.99 to $199.99.
- Stock levels vary between 10–500 units.
- Ratings are between 3.5–5.0 (simulating high-quality products).
- Structured Output: Each product has a unique ID and consistent attributes.
How to Use:
- Install
faker:pip install faker
- Run the script to generate 10 fake products. Modify
range(1, 11)to generate more/less data.
Sample Output Snippet:
Product ID: 1 Product Name: Elegant Innovation for Tomorrow Category: Electronics Price: $67.45 Stock: 234 Rating: 4.7/5.0 Description: Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit. Sed ut perspiciatis unde omnis iste natus error sit voluptatem. -------------------------------------------------- Product ID: 2 Product Name: Sleek and Modern Design Category: Clothing Price: $42.99 Stock: 87 Rating: 4.3/5.0 Description: At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti. --------------------------------------------------
This script is ideal for testing databases, building mock e-commerce platforms, or generating sample datasets for development.
Request an On-site Audit / Inquiry