【发布时间】:2020-05-08 00:30:28
【问题描述】:
我必须在一个巨大的 JSON 行文件中将所有出现的 \ 替换为 \\。我想使用 Powershell,但也可能有其他选择。
源文件有 4.000.000 行,大约 6GB。
我使用的 Powershell 脚本花费了太多时间,我让它运行了 2 个小时,还没有完成。半小时的表演是可以接受的。
$Importfile = "C:\file.jsonl"
$Exportfile = "C:\file2.jsonl"
(Get-Content -Path $Importfile) -replace "[\\]", "\\" | Set-Content -Path $Exportfile
【问题讨论】:
-
我将其添加到问题中。
标签: json powershell optimization