导入CSV,中间用;而不是PowerShell [英] Import-CSV separated by ; instead of , PowerShell
问题描述
我正在使用CSV存储一些我想在Powershell中使用的信息.为了使CSV更具可读性",我决定将每条信息放在一个单独的字段中.如果我在Powershell中使用import-csv
,则返回结果如下:
I'm using a CSV to store some information which I want to use in Powershell. To make the CSV more "readeable" I decided to put every piece of information into a separate field. If I use import-csv
in powershell, the return is like this:
Test1;Test2;Test3
-----------------
Val1;Val2;Val3
PowerShell无法处理;
-所以我问自己是否有任何办法可以立即导入CSV,但是请替换每个;".带有,",因此PowerShell会将其用作
PowerShell can't handle the ;
- so I was asking myself if there is any way to import the CSV as it is now, but replace every ";" with a "," so PowerShell will use it as
Test1 Test2 Test3
----- ----- -----
Val1 Val2 Val3
我这样尝试过
$test = (import-csv test.csv).Replace(";",",")
但是它不起作用
有人可以解决吗?预先谢谢你!
Does anyone have a solution? Thank you in advance!
推荐答案
Import-CSV
可以很好地处理;
分隔符-使用-delimiter ';'
-参数.
Import-CSV
can handle the ;
delimiter just fine - use the -delimiter ';'
-parameter.
这篇关于导入CSV,中间用;而不是PowerShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!