Hello,
I am not to familiar with Powershell, and have been tasked to use it a bit more.
I have a problem on correctly creating a Powershell script to import a .csv file with no headers and I need to modify the values only in the O column (0,1) to be either (no,yes) and then export the file. The .csv has columns of values A through O, but I only need to modify O only
I’m fairly certain on the import and export functions in the script, its how to do in between. Normally I would just configure the script to add a header row, but I can’t do this in this circumstance; after export I will need to import this file into an application as is.
Ideas?
3 Spice ups
Neally
(Neally)
2
Uh can you post an example of the .csv file what it looks like and what you want it to look like?
Please be advised you can not attach .csv, maybe just make it .txt
$headers = [string[]][char[]]([int][char]'A'..[int][char]'O')
$csv = Import-Csv -Path blah.csv -Header $headers
$out = ForEach($row in $csv) {
#some stuff with O
}
$out |
ConvertTo-Csv -NoTypeInformation |
Select-Object -Skip 1 |
Out-File -FilePath blah.csv -Encoding utf8
Those are my thoughts, untested. Basically inject the headers on import so you get the properties you can work with. Use convertto-csv instead of export-csv and skip the first line of output
2 Spice ups
DoctorDNS
(DoctorDNS)
4
Can you try the suggestions offered and post what you have. We try to avoid writing scripts for people and prefer to help them!