Imports System.IO Imports System.Text Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim srcFile As String = "C:\temp\1.csv" Dim sjis As Encoding = Encoding.GetEncoding("Shift_JIS") '元のcsvを読み込む Dim src = From row In File.ReadAllLines(srcFile, sjis) Where row <> "" Let cols = row.Split(",") Select New With {.姓 = cols(0), .科目 = cols(1), .点数 = CInt(cols(2))} '必要な科目分の列を持ったDataTableを用意 Dim tbl As New DataTable() tbl.PrimaryKey = {tbl.Columns.Add("姓")} For Each col In From row In src Select row.科目 Distinct tbl.Columns.Add(col, GetType(Integer)) Next 'DataTableに格納 For Each r In src Dim row = If(tbl.Rows.Find(r.姓), tbl.Rows.Add(r.姓)) row(r.科目) = r.点数 Next 'DataGridView に表示 DataGridView1.DataSource = tbl End Sub End Class