CCSV is a simple CSV parser written in pure C with the goal of mimic R and pandas dataframe. CCSV offers dataframe structure, descriptive statistis reports and linear regression model using least square method. For now, CCSV can handle only numerical dataset.
This example shows how to import a csv file, display statistical quantities and compute linear regression.
#include "ccsv.h"
#include "regression.h"
int main()
{
// Create dataframe reading data from csv file
DataFrame *df = read_csv("file.csv");
// Print all the dataframe
printDataFrame(df, ALL_LINE);
// ===== DESCRIPTIVE STATISTICs =====
// Array of columns to skip
// In this example first row is used for IDs
int col_skip[1] = {0};
// Print statistical summary
printSummary(df, skip, 1);
// Print correlation matrix
corr(df);
// ======= LINEAR REGRESSION =======
// Array of linear regression coefficients
double beta[8];
// Linear regression model specifications
LinearRegression model = {
.y_col = 8, // response column index
.beta = beta, // array of coefficients
// dimensionality of the regression
.x_cols = (int[]){1, 2, 3, 4, 5, 6, 7},
.x_cols_num = 7,
// true for print results
.print = true
};
// Compute linear regression
linearRegression(df, model);
// Deallocate dataframe
freeDataFrame(df);
return 0;
}CCSV use make as build system and OpenMP for multithreading.
- Clone the repository
git clone https://github.com/AlessandroMiotto/ccsv/ - Compile and run using make.
makewill create./builddirectory with the executable inside.For cleancd csv/ make make run./builddirectory, runmake clean
- Statistical summary
- Correlation analysis
- Regression models
- Add MKL support
- Histograms
- Multithreading support