Home » U++ Library support » U++ Library : Other (not classified elsewhere) » How to read from and write to a table in a file (CSV)?
Re: How to read from and write to a table in a file (CSV)? [message #10339 is a reply to message #10325] |
Tue, 03 July 2007 09:23   |
$mike{is_here}
Messages: 12 Registered: July 2007
|
Promising Member |
|
|
Hi Mirek,
Thanks, I used most of your ideas.
Dear all,
Because this post seems to catch some interest please find attached my solution (XP's zip). The functions
String cleanup(String s);
Vector<String> getLines(String s);
String load(char* filename);
bool save(const char *filename, const String& data);
String ToString(const Vector<String>& vs);
Vector<String> transpose(const Vector<String>& vs);
help to convert input.txt
A, B , C ,D
1,10 , 100, 5
2,20 , 200,55
into output.txt
A,1,2
B,10,20
C,100,200
D,5,55
Any suggestion, feedback or comments are welcome. This code so far does just the required minimum. I.e. it will fail when the number of elements vary. I wonder how to take care of such issues, e.g. through throwing exceptions (try, catch) or else?
What would you do?
Kind regards,
Micha
|
|
|
Goto Forum:
Current Time: Tue May 13 17:24:18 CEST 2025
Total time taken to generate the page: 0.03106 seconds
|