Delphi 5 -
Im trying to create a small app to import a text file into a database. i.e. I've got tick boxes for 'Does file include Column Headings?' and 'Type of Text File' 'Comma Seperated' / 'Tab Seperated'
My problems arrives when am trying to map the fields
Basically, depending on what the User selects 'Tab' or 'Comma', I want to display the first line in the text file, down 1 column in a StringGrid.
therefore if they pick 'Tab' it does the following -
Text File:
Forename Surname Mob Number
StringGrid:
Forename
Surname
MobNumber
Orif they pick 'Comma' it does the following -
Text File:
Forename,Surname,Mob Number
StringGrid:
Forename
Surname
MobNumber
My current code users 'CommaText' and therefore shows the StringGrid as
Forename
Surname
Mob
Number
Hope this is easy to understand - Any help or tips are welcome
Thanks
below is my current code:
oFileStrings := TStringList.Create;
oRowStrings := TStringList.Create;
oFileStrings.LoadFromFile(GetFileName);
for i := 0 to 0 do
begin
oRowStrings.Clear;
if GetColumnHeadings = False then
oRowStrings.CommaText := oFileStrings[0]
else
oRowStrings.CommaText := oFileStrings[1];
StringGrid1.cols.Assign(oRowStrings);
end;
oFileStrings.Free;
oRowStrings.Free;
Im trying to create a small app to import a text file into a database. i.e. I've got tick boxes for 'Does file include Column Headings?' and 'Type of Text File' 'Comma Seperated' / 'Tab Seperated'
My problems arrives when am trying to map the fields
Basically, depending on what the User selects 'Tab' or 'Comma', I want to display the first line in the text file, down 1 column in a StringGrid.
therefore if they pick 'Tab' it does the following -
Text File:
Forename Surname Mob Number
StringGrid:
Forename
Surname
MobNumber
Orif they pick 'Comma' it does the following -
Text File:
Forename,Surname,Mob Number
StringGrid:
Forename
Surname
MobNumber
My current code users 'CommaText' and therefore shows the StringGrid as
Forename
Surname
Mob
Number
Hope this is easy to understand - Any help or tips are welcome
Thanks
below is my current code:
oFileStrings := TStringList.Create;
oRowStrings := TStringList.Create;
oFileStrings.LoadFromFile(GetFileName);
for i := 0 to 0 do
begin
oRowStrings.Clear;
if GetColumnHeadings = False then
oRowStrings.CommaText := oFileStrings[0]
else
oRowStrings.CommaText := oFileStrings[1];
StringGrid1.cols.Assign(oRowStrings);
end;
oFileStrings.Free;
oRowStrings.Free;