今天写了个基恩士点云文件转txt的小工具,但是好慢..(Today, I wrote a small tool for keans point cloud file to TXT, but it’s so slow)

读取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);
						}
					}
				}
————————

Read the CSV file about 400 MB I don’t know if there is a faster writing method. I hope to be taught by a big man

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);
						}
					}
				}