-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv2pukiwiki.ps1
76 lines (67 loc) · 3.43 KB
/
csv2pukiwiki.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
$rawtext = Get-Content $Args[0]
$rawtext[0] = $rawtext[0] | ForEach-Object {
$_ -replace "status", "※" `
-replace "form factor", "規格" `
-replace "depth", "奥行" `
-replace "modular(?!\s)", "ケーブル" `
-replace "EPS8pin", "EPS 8pin" `
-replace "platform", "ベースモデル" `
-replace "pcb", "PCB" `
-replace "primary topology", "1次側方式" `
-replace "primary cap\(s\) brand", "1次側Cap(s)" `
-replace "secondary side topology", "2次側方式" `
-replace "secondary electrolytic caps brand", "2次側液体Caps" `
-replace "secondary solid caps brand", "2次側固体Caps" `
-replace "modular board caps", "プラグイン基板Caps" `
-replace "fan(?!less)", "ファン" `
-replace "fanless mode", "ファンレス" `
-replace "note", "備考" `
-replace "review/image_", "画像等"
}
$content = $rawtext | ForEach-Object {
$_ -replace "discontinued", "終売" `
-replace "Not Certified", "未取得" `
-replace "single sided", "片面"`
-replace "double sided", "両面"`
-replace "double forward", "ダブルフォワード" `
-replace "Active-Clamp", "アクティブクランプ" `
-replace "half-bridge", "ハーフブリッジ" `
-replace "full-bridge", "フルブリッジ" `
-replace "Semi-synchronous Rectification", "準同期整流" `
-replace "Synchronous Rectification", "同期整流" `
-replace "Passive Rectification", "ダイオード整流" `
-replace "Group Regulation", "12V/5V一括制御" `
-replace "Group\(5V/3\.3V\) Regulation", "5V/3.3V一括制御" `
-replace "鑫晖源", "(金金金)暉源" `
-replace "九州阳光电源", "九州陽光電源" `
-replace "japanese", "日本メーカー" `
-replace "unknown", "不明" `
-replace "JunFu", "JunFu" `
-replace "HongHua", "HongHua" `
-replace "MasterWatt", "MasterWatt" `
-replace "CapXon", "CapXon" `
-replace "XinHuiYuan", "XinHuiYuan" `
-replace "KuangJin", "KuangJin" `
} | ConvertFrom-Csv
$content | ForEach-Object {
#製品リンク生成
$_.name = "[[$($_.name):$($_.link)]]"
#値の置き換えと整形
$_."2次側液体Caps" = $_."2次側液体Caps" -creplace "/(?!a)", " / "
$_."2次側固体Caps" = $_."2次側固体Caps" -creplace "/(?!a)", " / "
$_."プラグイン基板Caps" = $_."プラグイン基板Caps" -replace "/(?!a)", " / "
#画像リンク生成 ※URLがある場合リンク化し、「-」の場合空欄にする
$_."画像等1" = if($_."画像等1" -ne "-"){"[[link:$($_."画像等1")]]"}else{""}
$_."画像等2" = if($_."画像等2" -ne "-"){"[[link:$($_."画像等2")]]"}else{""}
$_."画像等3" = if($_."画像等3" -ne "-"){"[[link:$($_."画像等3")]]"}else{""}
$_."画像等4" = if($_."画像等4" -ne "-"){"[[link:$($_."画像等4")]]"}else{""}
}
$content = $content | Select-Object * -ExcludeProperty "price", "link"
#pukiwiki記法テーブルへ変換
$csv = $content |
ConvertTo-Csv -Delimiter "|" -NoTypeInformation |
ForEach-Object {$_ -replace '"', ""}
$csv = $csv -replace "^(.+)$", '|$1|'
$csv[0] = $csv[0] + "h"
$out_pass = $Args[0] -replace ".csv", "_pukiwiki.txt"
[System.IO.File]::WriteAllLines($out_pass, $csv, $(New-object System.Text.UTF8Encoding))