Saturday, May 18, 2019

Powershell: Import-CSV

# -Delimeter option allows you to set separator value other than comma.
# Use -Encoding option to specify imported csv character set. The default is UTF8 without BOM.
> $test=Import-Csv .\KEN_ALL.CSV -Encoding Default

# Once you imported, you can manipulate the variable as array object.
> $test.Count
124267


> $test[112200]

a : 40133
b : 810
c : 8100001
d : フクオカケン
e : フクオカシチュウオウク
f : テンジン
g : 福岡県
h : 福岡市中央区
i : 天神
j : 0
k : 0
l : 1
m : 0
n : 0
o : 0


> $test | where { $_.b -match "^818" } | Format-Table -Property c ,g,h,i

c g h i
- - - -
8180000 福岡県 筑紫野市 以下に掲載がない場合
8180011 福岡県 筑紫野市 阿志岐
8180012 福岡県 筑紫野市 天山
8180068 福岡県 筑紫野市 石崎
8180014 福岡県 筑紫野市 牛島
8180034 福岡県 筑紫野市 美しが丘南


# Now you want to clear the variable!

> $test.Clear()

No comments:

Post a Comment