shell脚本读取csv_使用powershell读取Csv文件并捕获相应的数据

本文介绍了如何使用PowerShell高效地读取CSV文件,根据用户输入的“Store_Number”查找并捕获对应的数据,如“District_Number”,并将数据写入变量。通过对比Excel文件的读取速度,展示了PowerShell在处理CSV文件时的效率优势。示例中,通过Import-Csv命令导入CSV文件,然后遍历数据,根据用户输入的电话号码查找匹配的客户信息。
摘要由CSDN通过智能技术生成

Using PowerShell I would like to capture user input, compare the input to data in a comma delimited CSV file and write corresponding data to a variable.

Example:

A user is prompted for a “Store_Number”, they enter "10".

The input, “10” is then compared to the data in the first position

or column of the CSV file.

Data, such as “District_Number” in the corresponding position /

column is captured and written to a variable.

I have gotten this method to work with an Excel file (.xlsx) but have found it to be terribly slow. Hoping that PowerShell can read a CSV file more efficiently.

Link to an example CSV file here:

Store_Number,Region,District,NO_of_Devices,Go_Live_Date

1,2,230,10,2/21/2013

2,2,230,10,2/25/2013

3,2,260,12,3/8/2013

4,2,230,10,3/4/2013

5,2,260,10,3/4/2013

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值