【问题标题】:Read 4 column 1000 row txt file into Eclipse将 4 列 1000 行 txt 文件读入 Eclipse
【发布时间】:2018-09-10 19:04:51
【问题描述】:

我是编码新手,并且有一个程序可以将 1000 个 3d 点生成到一个 txt 文件中,用于生成散点图,在该散点图上放置一个椭球体。我需要执行一个椭球方程,将所有这些点读入一个循环,这将给我在椭球中有多少点的末尾的百分比。

如何将大的 txt 文件直接读入带有方程式的循环中?

我需要读入的方程是如果 (x/2)^2+(y/2)^2+(z/1)^2

感谢您的帮助!

【问题讨论】:

    标签: python eclipse


    【解决方案1】:

    你能分享你的文本文件格式吗?这对于如何过滤代码很重要。我在这个链接上找到了这个 sn-p:Read line by line a large text file and search for a string。我相信它会完成您想要的,因为您的文件格式有效。

     using (StreamReader streamReader = new StreamReader(this.MyPath))
        {
             while (streamReader.Peek() > 0)
             {
                  string line = streamReader.ReadLine();
    
                  if (line.Contains(Resources.Constants.SpecificString)
                  {
                       // Do some action with the string.
                  }
             }
        }
    

    【讨论】:

    • 它是 1000 行,有四列第一列是行号对于方程我真的不需要它第二、第三和第四是 3d 点的 x、y 和 z 坐标.我需要对所有 1000 行的 x、y 和 z 进行计算,最后知道有多少行符合方程标准
    猜你喜欢
    • 2015-12-13
    • 2019-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-17
    • 1970-01-01
    相关资源
    最近更新 更多