Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:03:34+00:00 2026-05-27T08:03:34+00:00

Fellow Overflowers, I have a tab delimited csv file which contains dates in this

  • 0

Fellow Overflowers,

I have a tab delimited csv file which contains dates in this format:
30-11-2011 2:24

I am parsing the csv with FasterSCV gem. I have created a migration which stores this info as datetime. Should I be doing that or define it as string and let Ruby convert it each time i retrieve it?

Do I need maybe to define some FasterCSV converters?

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:03:35+00:00Added an answer on May 27, 2026 at 8:03 am

    DateTime is a bit tricky. Is has a strict format

    irb(main):008:0> DateTime.now
    => Fri, 02 Dec 2011 22:14:57 +0100
    

    But you can do this

    irb(main):015:0> t = DateTime.parse("30-11-2011 2:24").utc
    => Wed, 30 Nov 2011 02:24:00 +0000
    irb(main):016:0> t.class
    => DateTime
    

    Now you have a DateTime object. But, pay attention to the time zone at the end of the parse method

    When you fill the database use the seeds.rb file in your db folder.
    I usually make a text file in the db folder, use my editor and replace all tabs with a “|” and make an array of each line
    Lets say it looks like this (asuming it is a todo list)

    todo file

    make hay|30-11-2011 2:24
    fix tractor|24-11-2011 2:14
    

    seeds.rb file

    open("db/todo") do |todos|
      todos.read.each_line do |todo|
        n = todo.chomp.split("|")
        Todo.create!(:entry => n[0], :at_date => DateTime.parse("#{n[1]}").utc)
      end
    end
    

    then run

    rake db:seed
    

    Make a some ruby magic!
    I have not tested this code, but it might push you in the right direction

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all fellow programmer I'd like to have a separate js file for each
Good morning fellow Overflowers, Small problem with model associations. I have these model associations:
Fellow Overflowers, Am working in a project in which I need to place (pin)
Fellow coders, i have a table that contains a number of rows each with
Fellow coders, I have asked this question before but did not get a conclusive
Hello fellow developers, I am a little stumped on this one as I have
hello fellow java developers. I'm having a bit of an issue here. I have
Hello fellow software developers. I want to distribute a C program which is scriptable
Avast there fellow programmers! I have the following problem: I have two rectangles overlapping
Hello fellow programmers, I have made a function that looks up the database if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.