今天写了个基恩士点云文件转txt的小工具,但是好慢..
读取csv文件大概400多mb..不知道有没有更快的写法,希望能有大佬教教
点击查看代码
OpenFileDialog openFileDialog1 = new OpenFileDialog();
string File_Name = "";
openFileDialog1.Filter = "所有文件(*.*)|*.*";
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
File_Name = openFileDialog1.FileName;
string new_Filename = File_Name.Split('.').First() + "new" + ".txt";
//实例化一个datatable用来存储数据
//DataTable dt = new DataTable();
List<double> KenyceYList = new List<double>();
List<List<double>> KenyceList = new List<List<double>>();
List<List<double>> KenyceLists = new List<List<double>>();
//List<double> CloudcompareYList = new List<double>();
//List<List<double>> CloudcompareList = new List<List<double>>();
//int Z = 0;
int Ymax = 0;
int Xmax = System.IO.File.ReadAllLines(File_Name).Count();
foreach (string item in System.IO.File.ReadLines(File_Name))
{
string[] temp = item.Split(',');
Ymax = temp.Count();
break;
}
int times = 0;
foreach (string item in System.IO.File.ReadLines(File_Name))
{
times++;
string[] temp = item.Split(',');
for (int i = 0; i < temp.Length; i++)
{
KenyceYList.Add(double.Parse(temp[i]));
}
List<double> templist = new List<double>(KenyceYList);
KenyceList.Add(templist);
KenyceYList.Clear();
}
using (StreamWriter writer = new StreamWriter(new_Filename, true))
{
for (int i = 0; i < Xmax - 1; i++)
{
for (int j = 0; j < Ymax - 1; j++)
{
string temp = i + "," + j + "," + KenyceList[i][j] * 0.015 + "\r\n";
writer.WriteLine(temp);
}
}
}
分类:
CloudCompare
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix