3

I have a text file that has a date followed by temperature values. I am converting it to a .csv file with the help of following command:

Import-Csv D:\Arduino\sketch_lm35\11-04-17-LM35.txt -Delimiter "`t" |
    Export-Csv D:\Arduino\sketch_lm35\test.csv -NoTypeInformation

So the generated .csv file will have the date as the first column and temperature as the second column. Now I need to insert a serial number as the first column in the .csv file. How can it be done with PowerShell?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Ramya
  • 177
  • 3
  • 12

1 Answers1

3

Use calculated properties for adding columns to a CSV:

Import-Csv ... | Select-Object @{n='Serial';e={...}}, * | Export-Csv ...
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328