Board index » delphi » Import / Export - where I have to implement the logic

Import / Export - where I have to implement the logic


2008-07-23 05:34:30 PM
delphi1
Hello,
I have to write a programm which imports some csv files and export this data
to an other csv format.
The simplest thing is to write something like this:
Liste.LoadFromCSVFile();
for i := 0 to Liste.Count - 1 do
Liste1.Add(extractColumn(Liste[i],2) + ';' + AdditionalInformation + ';' +
extractColumn(Liste[i],5));
Liste1.SaveToFile();
But the import/export is a little bit complexer. There are some lines in the
source which I have to ignore. Some data I have to
generate from two or more source files to one target file. Some data must be
add to target manuallay and something is hard coded.
Some data values I have to convert, for example boolean fields. In source
there are true and false fields in target I have to
write 0 or 1. Or float fields in source with '.' (10.1) and in target there
are two fields ...;10;1;... and so on.
Now my question: How can I manage the import/export or the data conversion?
My idea was to import the whole csv files (source) to a logical
data-object-graph. With an import class and some lists for each csv file.
Than I'd write a export class, which uses the import class to generate
the output.
Is this solution a good one? Where did I have to implement the logic? In the
import or export class? Did the import class have to be
type safe (integer, float because in csv is everything a "string") or must
be the export class "type safe".
Sorry for my bad english and thanks for anny suggestions.
Regards M.Pannier
 
 

Re:Import / Export - where I have to implement the logic

Hello,
I have to write a programm which imports some csv files and export this data
to an other csv format.
The simplest thing is to write something like this:
Liste.LoadFromCSVFile();
for i := 0 to Liste.Count - 1 do
Liste1.Add(extractColumn(Liste[i],2) + ';' + AdditionalInformation + ';' +
extractColumn(Liste[i],5));
Liste1.SaveToFile();
But the import/export is a little bit complexer. There are some lines in the
source which I have to ignore. Some data I have to
generate from two or more source files to one target file. Some data must be
add to target manuallay and something is hard coded.
Some data values I have to convert, for example boolean fields. In source
there are true and false fields in target I have to
write 0 or 1. Or float fields in source with '.' (10.1) and in target there
are two fields ...;10;1;... and so on.
Now my question: How can I manage the import/export or the data conversion?
My idea was to import the whole csv files (source) to a logical
data-object-graph. With an import class and some lists for each csv file.
Than I'd write a export class, which uses the import class to generate
the output.
Is this solution a good one? Where did I have to implement the logic? In the
import or export class? Did the import class have to be
type safe (integer, float because in csv is everything a "string") or must
be the export class "type safe".
Sorry for my bad english and thanks for anny suggestions.
Regards M.Pannier