Fabric-language-kotlin
python generate_data.py // Main.kt import kotlinx.serialization.* import kotlinx.serialization.json.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import java.io.File import java.time.Instant import java.time.LocalDate import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.time.temporal.ChronoUnit // Data classes matching Fabric's output @Serializable data class Preferences( val language: String, val notifications: Boolean )
// 2. Age distribution val ageGroups = users.groupBy { when (it.age) { in 18..25 -> "18-25" in 26..40 -> "26-40" in 41..60 -> "41-60" else -> "60+" } } println("\nAge distribution:") ageGroups.forEach { (group, list) -> println(" $group: ${list.size} users") } fabric-language-kotlin
# generate_data.py # Install fabric: pip install fabric from fabric import Fabricator import json import random from datetime import datetime, timedelta Define a simple data model using Fabric's declarative syntax user_fabricator = Fabricator( schema={ "user_id": "uuid", "full_name": "name", "email": "email", "age": {"type": "integer", "min": 18, "max": 90}, "signup_date": {"type": "date", "start": "2023-01-01", "end": "2025-12-31"}, "is_active": {"type": "boolean", "probability": 0.85}, "last_login": {"type": "datetime", "start": "2025-01-01", "end": "2025-04-14"}, "preferences": { "type": "dict", "schema": { "language": {"type": "choice", "choices": ["Kotlin", "Python", "Java", "Rust"]}, "notifications": "boolean" } } } ) python generate_data
dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3") } "18-25" in 26..40 ->
Run:
Active users by language preference: Java: 198 Kotlin: 213 Python: 197 Rust: 192