如何使用powershell重新排序CSV列 [英] How to use powershell to reorder CSV columns

查看:236
本文介绍了如何使用powershell重新排序CSV列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入文件:

column1;column2;column3
data1a;data2a;data3a
data1b;data2b;data3b

目标:带有重新排序的列的输出文件,例如

Goal: output file with reordered columns, say

column1;column3;column2
...


b $ b

UPDATED问题:
什么是使用powershell解决这个问题的好方法。
我知道CSV相关cmdlet的存在,但这些都有局限性。
注意,记录的顺序不需要改变,所以不需要在内存中加载整个输入/输出文件。

UPDATED Question: What is a good way of using powershell to solve this problem. I am aware of the existence of CSV related cmdlets, but these have limitations. Note that the order of records does not need to be changed, so loading the entire input/output file in memory should not be needed.

推荐答案

Import-CSV C:\Path\To\Original.csv | Select-Object Column1, Column3, Column2 | Export-CSV C:\Path\To\Newfile.csv

这篇关于如何使用powershell重新排序CSV列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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