Skip to content

Instantly share code, notes, and snippets.

@royashbrook
Created February 27, 2018 19:40
Show Gist options
  • Save royashbrook/8285c8511854e60ffe22958c98dfe0e5 to your computer and use it in GitHub Desktop.
Save royashbrook/8285c8511854e60ffe22958c98dfe0e5 to your computer and use it in GitHub Desktop.
# Long way with some explanation
$FilePath = "path_to_ file"
$FileContents = gc $FilePath
$Commas = $FileContents[0].Split(',').Count
$Columns = $Commas + 1
$Header = (1..$Columns|%{"f{0,2:00}" -f $_})
$Data = $FileContents | ConvertFrom-Csv -Header $Header
$Data | Format-Table *
# What I usually do is something more like
$d = gc "path_to_ file"
$h = 1..($d[0].split(',').count + 1)|%{"f{0,2:00}" -f $_}
$d | convertfrom-csv -h $h | select -first 5 | ft *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment