I have a CSV file that with contents that needs to be converted to all lowercase
I have tried the code below but it doesn't maintain the CSV structure.
(Get-Content C:\_Scratch\export.csv).ToLower() | Out-File C:\_scratch\export.csv
$Init = Import-Csv C:\_Scratch\export.csv
Is there another option I can try?
Get-Content
is going to give you string array. Add the -Raw
switch to read it in as a single string, and the .toupper()
and .tolower()
string methods should work on that.
(Get-Content C:\_Scratch\export.csv -Raw).ToLower() | Out-File C:\_scratch\export.csv
$TempContentArray = $NULL
$TempContent = $NULL
$TempContent = Get-Content C:\_Scratch\import.csv
Foreach ($Line in $TempContent)
{
$TempContentArray += $Line.ToUpper()
}
$TempContentArray | C:\_scratch\export.csv
$Init = Import-Csv C:\_Scratch\export.csv
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.