SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: reading a file?

  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,666
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    reading a file?

    this code opens up the csv file
    Code:
    require 'csv'
    require 'date'
    
    
    contents = CSV.open 'event_attendees.csv', headers: true, header_converters: :symbol
    
    
    
    contents.each do |row|
      name = row[:first_name] +" "+ row[:last_name]
    
      regdate = row[:RegDate]
    
      puts "#{name} registered on #{regdate}"
    end
    problem is the RegDate thing isn't being read, heres the output
    Allison Nguyen registered on
    Sarah ...

    and heres the CSV file
    ,RegDate,first_Name,last_Name,Email_Address,...
    10:47,Allison,Nguyen,arannon@jumpstartlab.com,... 13:23,SArah,Hankins,pinalevitsky@jumpstartlab.com,...
    why is the RegDate not showing?

    Thanks...
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,666
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    it worked when I changed the symbol to all lower case
    Code:
      regdate = row[:regdate]
    Why was That?
    "Oh, and Jenkins--apparently your mother died this morning."

  3. #3
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    The convention, in Ruby, for symbols is lower(snake)case.
    I am not sure of the background, 'technical' reason for that.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  4. #4
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,666
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    ok, thx
    "Oh, and Jenkins--apparently your mother died this morning."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •