locked
Import-csv - show header only RRS feed

  • Question

  • Hi,

    I'm using Import-csv, and I was wondering if there is a way to get or show the header only

    Thank you

     

    Thursday, December 2, 2010 6:32 PM

Answers

  • If you want to do it on the imported .csv,

    $a = import-csv filename.csv

    $a[0] | gm -membertype noteproperty | select name


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Marked as answer by Cyreli Friday, December 3, 2010 4:57 AM
    Thursday, December 2, 2010 6:48 PM

All replies

  • get-content filename.csv -totalcount 1

    Should get you just the header row.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Thursday, December 2, 2010 6:42 PM
  • If you want to do it on the imported .csv,

    $a = import-csv filename.csv

    $a[0] | gm -membertype noteproperty | select name


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Marked as answer by Cyreli Friday, December 3, 2010 4:57 AM
    Thursday, December 2, 2010 6:48 PM
  • Don't forget to split on the commas:

    (gc filename.csv.csv -TotalCount 1) -split ','


    http://twitter.com/toenuff
    write-host ((0..56)|%{if (($_+1)%3 -eq 0){[char][int]("116111101110117102102064103109097105108046099111109"[($_-2)..$_] -join "")}}) -separator ""
    • Proposed as answer by Marco Shaw Friday, December 3, 2010 1:42 AM
    Thursday, December 2, 2010 9:46 PM