A functional programming console application written in F# that performs universal CSV data analysis using functional programming principles.
- Universal CSV Parser: Automatically detects and parses any CSV file with headers
- Type-Safe Data Processing: Uses F#'s type system for safe data handling
- Functional Programming: Demonstrates core FP concepts including:
- Immutable data structures (records, maps)
- Higher-order functions (map, filter, groupBy, fold)
- Function composition with pipeline operator (|>)
- Pattern matching for type detection
- Lazy sequences for efficient processing
The project includes several sample CSV files for testing:
- Product sales with categories, quantities, and prices
- Demonstrates business data analysis
- Sample output: Total sales $10,569.65, category breakdowns
- Employee information with salaries, experience, and ratings
- Shows HR/analytics data processing
- Sample output: Average salary $67,500, department ratings
- Academic data with grades, attendance, and study hours
- Educational metrics analysis
- Sample output: Average grade 85.13, attendance 90.88%
- Environmental data with temperature, humidity, wind speed
- Temporal and geographic data handling
- Sample output: Average temperature 45.11°F, city-based humidity analysis
dotnet runThis will analyze the default data.csv file.
dotnet run your_file.csvThe application automatically performs:
- Row Count: Total number of data records
- Numeric Column Detection: Identifies columns with numeric data
- Statistical Analysis: For each numeric column:
- Count of values
- Sum and average
- Minimum and maximum values
- Grouped Analysis: Groups data by the first column and analyzes numeric columns
type CsvRow = Map<string, obj>Uses immutable maps to represent CSV rows.
let parseValue (value: string) =
match Int32.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture) with
| true, i -> box i
| _ -> // Try other types...Type-safe value parsing with pattern matching.
let columnStats (rows: seq<CsvRow>) column =
rows
|> Seq.choose (fun row -> /* extract numeric values */)
|> Seq.toList
|> List.sum // Sum using foldFunction composition for data transformation.
rows
|> Seq.groupBy (fun row -> /* grouping logic */)
|> Seq.map (fun (key, groupRows) -> /* analysis */)Readable data processing pipelines.
- Ensure you have .NET SDK installed
- Clone or download this repository
- Navigate to the project directory
- Run
dotnet restoreto restore packages - Run
dotnet runto execute
The application works with any CSV file that:
- Has a header row with column names
- Contains numeric data in at least one column
- Uses comma separation
Example format:
Column1,Column2,Column3,Column4
value1,value2,123,45.6
value1,value2,456,78.9readCsv: Reads and parses CSV files into typed data structuresparseValue: Type-safe value parsing with automatic type detectioncolumnStats: Statistical analysis of numeric columnsgroupByColumn: Grouped analysis functionalitygetNumericColumns: Automatic detection of numeric data
The application includes robust error handling for:
- Missing files
- Invalid data formats
- Type conversion errors
- Empty datasets
This project demonstrates functional programming best practices in F#. Feel free to:
- Add new sample datasets
- Enhance analysis capabilities
- Improve error handling
- Add new functional programming examples
This project is open source and available under the MIT License.