今天寫了個基恩士點雲文件轉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);
						}
					}
				}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章