#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    1
    Rep Power
    0

    Unhappy reading csv file & passing to array


    Hi,

    could you guys help me on this,

    I need to read the csv file and passing all the value within my csv file into array.

    my csv file have only two simple columns shown below:

    AUD 0.72
    JPY 200.3
    EUR 0.22
    USD 0.30

    and I try to use this method to read the csv file

    ...
    begin
    assign(myfile,'currency.csv');
    reset(myfile);
    my_outline := TStringList.Create;

    while not eof(myfile) do
    begin
    readln(myfile, line);
    my_outline.DelimitedText := line;
    .....

    then I dont know how to pass all the value to array..

    please help

    kind regards
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4247
    my_Outline.Text will give you the complete text of the string list. If you want it as multiple lines, then you can use the my_Outline.Strings property something like this:
    Code:
    var
       i : integer;
       s : string;
    begin
        for i := 0 to my_Outline.Count - 1 do
        begin
            s := my_Outline.Strings[i];
            s := my_Outline[i]; // Same as previous line
        end;
    end;
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo