gpt4 book ai didi

c# - 从特定行号(例如 2 到 50)读取 CSV 文件

转载 作者:行者123 更新时间:2023-12-02 13:57:54 27 4
gpt4 key购买 nike

我有一个 .csv 文件,当前已读取所有行:

 string csv = File.ReadAllText(@inputfile);

假设该文件中有 100 行。我只想从第二行读到第 50 行。如何在 C# 中做到这一点?

最佳答案

您可以将 ReadLines 方法与 LINQ 结合使用:

File.ReadLines(inputFile).Skip(2).Take(48);

关于c# - 从特定行号(例如 2 到 50)读取 CSV 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51818586/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com