Read from XLS and substitute values in Ruby (Watir)

Discussion in 'Ruby' started by Madu Nar, Sep 8, 2006.

  1. Madu Nar

    Madu Nar Guest

    Hello there,
    I am trying to read multiple columns from an xls file and substiture
    those values into a text_field

    Ex: My xls contains
    User Name password
    aaa abc321
    bbb abc123


    I need to pass each row of records into a text_fields for username and
    password and click on go...

    I need to do this till the end of the file... could somebody tell me as
    to how I parameterize the values for the text fields so that it
    automatically picks up the records for each row...

    Any help is greatly appreciated.

    Thank you,
    MN

    --
    Posted via http://www.ruby-forum.com/.
     
    Madu Nar, Sep 8, 2006
    #1
    1. Advertising

  2. Madu Nar

    Madu Nar Guest

    Hello Paul,
    Thank you so much for the Info...
    I tried and it did work. But, how do I pass each of those split
    tokens as separate parameters for the text fields.

    Ex: ie.text_field:)name,
    "SearchFormHandler.searchTerms").set("Brian Kantz")
    ie.select_list:)name,
    "SearchFormHandler.state").select("California")

    So the values Brian Kantz, California should be automatically
    substituted from the file... Your help is greatly appreciated...

    Thanks,
    Madu

    Paul Lutus wrote:

    > Madu Nar wrote:
    >
    >> I need to pass each row of records into a text_fields for username and
    >> password and click on go...
    >>
    >> I need to do this till the end of the file... could somebody tell me as
    >> to how I parameterize the values for the text fields so that it
    >> automatically picks up the records for each row...

    >
    > In your example above, one of the field names is "User Name", with a
    > space.
    > Yet the field separator for the data records below it appears to uses
    > one
    > or more spaces as delimiters. On the other hand, it might be tabs, hard
    > to
    > tell from your post.
    >
    > Let's assume that tabs are used instead of spaces between the fields. If
    > that is true, then (untested):
    >
    > File.read("filename").each do |record|
    > record.split("\t").each do |field|
    > # your turn
    > end
    > end



    --
    Posted via http://www.ruby-forum.com/.
     
    Madu Nar, Sep 11, 2006
    #2
    1. Advertising

  3. Madu Nar

    Madu Nar Guest

    Also,Is there a way to read from csv file or xls file because currently
    I am trying to read from a txt file.
    Should I Require/import any particular libraries before trying to read
    from a CSV or an xls file.
    Any help appreciated.

    Thanks again,
    Madu

    Madu Nar wrote:
    > Hello Paul,
    > Thank you so much for the Info...
    > I tried and it did work. But, how do I pass each of those split
    > tokens as separate parameters for the text fields.
    >
    > Ex: ie.text_field:)name,
    > "SearchFormHandler.searchTerms").set("Brian Kantz")
    > ie.select_list:)name,
    > "SearchFormHandler.state").select("California")
    >
    > So the values Brian Kantz, California should be automatically
    > substituted from the file... Your help is greatly appreciated...
    >
    > Thanks,
    > Madu
    >
    > Paul Lutus wrote:
    >
    >> Madu Nar wrote:
    >>
    >>> I need to pass each row of records into a text_fields for username and
    >>> password and click on go...
    >>>
    >>> I need to do this till the end of the file... could somebody tell me as
    >>> to how I parameterize the values for the text fields so that it
    >>> automatically picks up the records for each row...

    >>
    >> In your example above, one of the field names is "User Name", with a
    >> space.
    >> Yet the field separator for the data records below it appears to uses
    >> one
    >> or more spaces as delimiters. On the other hand, it might be tabs, hard
    >> to
    >> tell from your post.
    >>
    >> Let's assume that tabs are used instead of spaces between the fields. If
    >> that is true, then (untested):
    >>
    >> File.read("filename").each do |record|
    >> record.split("\t").each do |field|
    >> # your turn
    >> end
    >> end



    --
    Posted via http://www.ruby-forum.com/.
     
    Madu Nar, Sep 11, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vighnesh
    Replies:
    3
    Views:
    1,040
    Paul Clement
    Aug 4, 2005
  2. Wayne Wengert

    Substitute Values in Column in Gridview

    Wayne Wengert, Mar 11, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    770
    Wayne Wengert
    Mar 11, 2006
  3. Jeff Kish
    Replies:
    2
    Views:
    939
    Jeff Kish
    Nov 15, 2004
  4. vighnesh
    Replies:
    3
    Views:
    199
    Paul Clement
    Aug 4, 2005
  5. Anukul Singhal
    Replies:
    1
    Views:
    183
    Charley Baker
    May 15, 2008
Loading...

Share This Page