Home » U++ Library support » U++ Core » Is there a token function?
Re: Is there a token function? [message #2717 is a reply to message #2716] |
Sat, 22 April 2006 22:39   |
 |
mirek
Messages: 14267 Registered: November 2005
|
Ultimate Member |
|
|
Well, if you are not to process 100MB+ files that are not well divided into lines and has similar lexical syntax to C, the easiest and fastest U++ way is to LoadFile into String and then use CParser.
If you DO want to process 100MB+ files and/or they are divided into lines, usually you can use similar approach, just use CParser per each single line. Or process it in any other way - in this particular case, I believe "Split" would be the best option (as you have fields separated by ';').
BTW, what you present is kind of import I have to provide for my customers quite often. Skeleton of such parser usually looks like
FileIn in(path_to_file);
in.GetLine(); // to eat "header" line
try {
while(!in.IsEof()) {
Vector<String> field = Split(in.GetLine(), ';');
if(field.GetCount() != 11)
throw CParser::Error("");
String name = field[0];
String coutnry = field[1];
CParser p(field[2]);
Date d;
d.day = p.ReadInt();
p.PassChar('.');
d.month = p.ReadInt();
p.PassChar('.');
d.year = p.ReadInt();
if(d.year < 20)
d.year += 2000;
else
if(d.year < 100)
d.year += 1900;
}
}
catch(CParser::Error) {
// invalid file
}
[Updated on: Sun, 23 April 2006 10:03] by Moderator Report message to a moderator
|
|
|
 |
|
Is there a token function?
By: forlano on Sat, 22 April 2006 22:06
|
 |
|
Re: Is there a token function?
By: mirek on Sat, 22 April 2006 22:39
|
 |
|
Re: Is there a token function?
By: fudadmin on Sun, 23 April 2006 11:50
|
 |
|
Re: Is there a token function?
By: forlano on Sun, 23 April 2006 13:31
|
 |
|
Re: Is there a token function?
By: fudadmin on Sun, 23 April 2006 13:35
|
 |
|
Re: Is there a token function?
By: forlano on Sun, 23 April 2006 13:55
|
 |
|
Re: Is there a token function?
By: fudadmin on Sun, 23 April 2006 13:57
|
 |
|
Re: Is there a token function?
By: fudadmin on Sun, 23 April 2006 13:59
|
 |
|
Re: Is there a token function?
By: forlano on Sun, 23 April 2006 14:19
|
 |
|
Re: Is there a token function?
By: mirek on Sun, 23 April 2006 14:50
|
 |
|
Re: Is there a token function?
By: fudadmin on Sun, 23 April 2006 15:33
|
 |
|
Re: Is there a token function?
By: fudadmin on Sun, 23 April 2006 15:36
|
 |
|
Re: Is there a token function?
By: mirek on Sun, 23 April 2006 15:44
|
 |
|
Re: Is there a token function?
By: fudadmin on Mon, 24 April 2006 01:01
|
 |
|
Re: Is there a token function?
By: mirek on Mon, 24 April 2006 01:14
|
Goto Forum:
Current Time: Thu Sep 04 00:56:08 CEST 2025
Total time taken to generate the page: 0.04961 seconds
|