//
stai leggendo...
domanda

off with his head

Powershell e il problema dei CSV senza riga di intestazione

Richard Siddaway's Blog

CSV files are great for passing information around and are very easy to use in your PowerShell scripts. Sometimes, your CSV may have a problem – for instance it doesn’t have a header row. At that point the data becomes a bit difficult to use:

£ Import-Csv .\htest.csv | Format-Table -AutoSize

Luckily there is an answer.  Create your own headers:

£ Import-Csv .\htest.csv -Header “Number”, “Colour”, “Price”, “Total” | Format-Table -AutoSize

Makes much more sense now.

You can also override existing headers

£ Import-Csv .\htest.csv -Header “Number”, “Colour”, “Price”, “Total”  |
>> select -Skip 1 | Format-Table -AutoSize
>>

The select call is used to skip the old header row.

If you run queries in SQL Studio Management Studio and export the results to a CSV file you will get a file without headers. This technique comes in useful at that point.

View original post

Annunci

Discussione

Non c'è ancora nessun commento.

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: