今天写了个基恩士点云文件转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);
}
}
}