如何使用Powershell脚本删除csv文件中的所有引号? [英] How to remove all quotations mark in the csv file using powershell script?

查看:153
本文介绍了如何使用Powershell脚本删除csv文件中的所有引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除导出的csv文件中的所有引号字符,当我生成一个新的csv文件并且需要手动删除字符串中包括的所有引号时,这很烦人.谁能为我提供一个Powershell脚本来克服这个问题?谢谢.

I would like remove all quotations character in my exported csv file, it's very annoying when i generated a new csv file and i need to manually to remove all the quotations that include in the string. Could anyone provide me a Powershell script to overcome this problem? Thanks.

$File = "c:\programfiles\programx\file.csv"
(Get-Content $File) | Foreach-Object {
    $_ -replace """, ""
} | Set-Content $File

推荐答案

下次创建一个时,powershell 7中的export-csv有一个新选项,您可能会喜欢:

Next time you make one, export-csv in powershell 7 has a new option you may like:

export-csv -UseQuotes AsNeeded

这篇关于如何使用Powershell脚本删除csv文件中的所有引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆