David Li
3 min readSep 14, 2023

Polygot notebooks are a fanastic way to do data science. They allow you to use multiple languages in a single notebook. My personal preference is the vs code extension formerly .net interactive offered as a vs code extension.

Using the code from https://towardsdev.com/how-to-rank-software-engineers-using-bash-c8b1bd8885fb,

I can grab the data from the CSV file and put it into a list of strings.

using System.IO;
using System.Linq;
using System.Globalization;
using CsvHelper;
using System;

// Read data from CSV file
var records = new List<dynamic>();
using (var reader = new StreamReader("data/changes_by_file.csv"))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
records = csv.GetRecords<dynamic>().ToList();
}

// Extract data for chart
var counts = records.Select(r => r.Count);
var file = records.Select(r => r.File);

// export authors as list of string
var countsList = counts.ToList();
// get value from counts
var fileList = file.ToList();

The script reads data from a CSV file located at “data/changes_by_file.csv” using CsvHelper library to parse the CSV file. It creates a list of dynamic objects where each object represents a row in the CSV file.

After reading the data, it extracts two columns from the CSV file: “Count” and “File” by projecting them into separate lists using Linq.

Finally, it exports the counts list and file list as separate variables called countsList and fileList, respectively, by converting them to a list using ToList() method.

David Li
David Li

Written by David Li

Software developer that is an active bogger.

No responses yet