Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Read txt, analyze and convert to csv
Re: Read txt, analyze and convert to csv [message #53208 is a reply to message #53203] Fri, 20 March 2020 09:40 Go to previous messageGo to previous message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Good! thanks you so much!

The while cicle take a lot of time because the file I'm going to read is 800k rows so I decided to introduce a ProgressIndicator to monitor it. The problem is that at the moment the progress indicator appear only at the end of the process so it is useless... Why?

PriceListGenerator::PriceListGenerator()
{
	CtrlLayout(*this, "PriceList Generator");
	
	//menĂ¹-tool-status
	AddFrame(menu);
	AddFrame(tool);
	AddFrame(status);
	menu.WhenHelp = status;
	tool.WhenHelp = status;
	menu.Set(THISBACK(MainMenu));
	tool.Set(THISBACK(SubBar));
	
	//Progress
	status.Add(pi.RightPos(5, 200).TopPos(2, 15));   //Indicator inside my statusBar
	pi.Percent();
	pi.Hide();

	//String s = LoadFile(TXT_file_path);
	generate <<= THISBACK(LoadPriceList);
	//LoadPriceList(s);
}

void PriceListGenerator::LoadPriceList()
{
	String s = LoadFile("C:\\Users\\Matteo\\Desktop\\prova.txt");
	StringStream ss(s);
	
	int x = 0;
	pi.Show();
	//pi.Set(x,1000); //how can I get the right number of rows?
	
	FileOut out("C:\\Users\\Matteo\\Desktop\\output.csv");
	out << AddHeader();
	
	while(!ss.IsEof() && !ss.IsError())
	{
		String line = ss.GetLine();
		Vector<String> fields = SpliteLine(line);
                pi.Set(x++);                       // ProgressIndicator
		
		if(!fields.GetCount()) continue;
		
		String r = CsvString(fields[0]);
		for(int i = 1; i < fields.GetCount(); i++)
		{
			r << ";" << CsvString(fields[i]);
		}
		r << "\n";
		out << r;
	}
}


It could be a problem about statusBar?
Moreover, if I would like to show the percentage how can I get the total number of rows?

Best,
Matteo
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon14.gif
Previous Topic: [SOLVED] Cloning Array of complexe type
Next Topic: OptionTree inside a DropTree
Goto Forum:
  


Current Time: Mon May 06 08:14:12 CEST 2024

Total time taken to generate the page: 0.02548 seconds