Change value in column using powershell -


i have csv file 5 columns. last column being students grade level. want change value of column based on gradelevel. example if gradelevel 12 want change 2016, 11 2017, on , forth.

update: did semi work using below:

get-content users.csv | foreach-object -process {$_ -replace '12','2016'} | set-content users1.csv 

what happens if student id has 12 in gets changed 2016. example 120045 gets change 20160045

you can import csv, loop in foreach , use $_ (this) operator , export ist csv

somesthing like:

# import csv $list = import-csv p:\ath\to\file.csv -delimiter ";" -encoding standard # % means foreach $list | % {   # grades key each line   # first line of csv represent keys can use   # e.g. first colum: name | grade | class   # $_.name | $_.grade | $_.class keys every entry (2nd line , above)    # here can work grades want   if($_.grade -eq 11){      # set new value grade in actual line      $_.grade = 2016   }   }  # export new list csv export-csv p:\ath\to\new.csv -delimiter ";" -notypeinformation 

that should basic work with.

greetz eldo.o


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -