进口CSV永远使用PowerShell

发布于 2025-01-24 22:58:28 字数 121 浏览 4 评论 0原文

我正在尝试import-csv是3GB并将其存储在变量中,然后根据所有数据运行脚本。我需要文件中的所有信息。导入命令需要花费数小时才能导入数据。是否有更快的方法可以实现这一目标?

谢谢

I am trying to import-csv of a file that is 3GB and store it in a variable and then run a script based on all that data. I need all the information in the file. The import command is taking hours though to import the data. Is there a faster way to accomplish this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坠似风落 2025-01-31 22:58:28

查看system.io.io.streamreadersystem.io.file。当我不得不处理一个大数十或数十万行-CSV文件时,这是我以任何效率进行操作的唯一方法。

这是一个例子。

$FileReader = [System.IO.File]::OpenText($FileName)
While ($FileLine = $FileReader.ReadLine())
{
    # Do Things with $FileLine
}
$FileReader.Close()

Look into System.IO.StreamReader and System.IO.File. When I had to process a large - tens or hundreds of thousands of lines - CSV file, that was the only way I could do it with any efficiency.

Here's an example.

$FileReader = [System.IO.File]::OpenText($FileName)
While ($FileLine = $FileReader.ReadLine())
{
    # Do Things with $FileLine
}
$FileReader.Close()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文