Home » Community » Newbie corner » Read txt, analyze and convert to csv
Re: Read txt, analyze and convert to csv [message #53192 is a reply to message #53183] |
Tue, 17 March 2020 09:45   |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
you can start with this:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
Vector<String> SpliteLine(String& line)
{
// example
return Split(line, "\t", false);
}
GUI_APP_MAIN
{
String s = LoadFile(TXT_file_path);
StringStream ss(s);
FileOut out(csv_file_path);
while(!ss.IsEof() && !ss.IsError())
{
String line = ss.GetLine();
Vector<String> fields = SpliteLine(line);
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;
}
}
regards
omari.
|
|
|
 |
|
Read txt, analyze and convert to csv
By: idkfa46 on Sun, 15 March 2020 16:52
|
 |
|
Re: Read txt, analyze and convert to csv
By: omari on Tue, 17 March 2020 09:45
|
 |
|
Re: Read txt, analyze and convert to csv
By: idkfa46 on Wed, 18 March 2020 13:27
|
 |
|
Re: Read txt, analyze and convert to csv
By: omari on Wed, 18 March 2020 17:31
|
 |
|
Re: Read txt, analyze and convert to csv
By: idkfa46 on Fri, 20 March 2020 09:40
|
 |
|
Re: Read txt, analyze and convert to csv
By: idkfa46 on Mon, 23 March 2020 13:21
|
 |
|
Re: Read txt, analyze and convert to csv
By: omari on Tue, 24 March 2020 15:20
|
 |
|
Re: Read txt, analyze and convert to csv
By: idkfa46 on Tue, 24 March 2020 15:52
|
 |
|
Re: Read txt, analyze and convert to csv
By: idkfa46 on Wed, 25 March 2020 20:26
|
 |
|
Re: Read txt, analyze and convert to csv
By: idkfa46 on Thu, 26 March 2020 10:50
|
 |
|
Re: Read txt, analyze and convert to csv
By: idkfa46 on Tue, 31 March 2020 09:57
|
 |
|
Re: Read txt, analyze and convert to csv
By: omari on Tue, 31 March 2020 15:17
|
 |
 |
Re: Read txt, analyze and convert to csv
By: idkfa46 on Tue, 31 March 2020 16:35
|
Goto Forum:
Current Time: Fri Jun 20 17:59:35 CEST 2025
Total time taken to generate the page: 0.04386 seconds
|