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 9047635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:57:30+00:00 2026-06-16T11:57:30+00:00

I wrote a python script that takes a csv which has dates in an

  • 0

I wrote a python script that takes a csv which has dates in an M/D/YYYY format, then matches them with dates in an xlwt generated .xls file. I was wondering why only some dates are matched and then I noticed that the only dates that were matched were strings that were 10 characters long (11/14/2011) and dates that were not 10 characters long (1/14/2011 or 1/7/2012) were not matched. How do I get the csv file to save the dates in 10 character long strings? Or should I convert the csv file into a txt file?

  • 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-06-16T11:57:31+00:00Added an answer on June 16, 2026 at 11:57 am

    csv doesn’t know anything about dates; it just reads text. You are comparing strings with other strings, and '1/7/2012' and '01/07/2012' are different strings altogether.

    You’d need to parse the dates into something that can be compared, when reading. Use the datetime.datetime.strptime() function for that:

    import datetime
    
    dt = datetime.datetime.strptime(datecolumn, '%m/%d/%Y').date()
    

    The strptime() format above would turn both 1/7/2012 and 01/07/2012 into a datetime.date(2012, 1, 7), and two copies of that date() instance would compare as equal.

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

Sidebar

Related Questions

I just wrote a python script that takes an input csv, and outputs a
I wrote a Python script that does some task to generate, and then keep
I am trying to write a python script that takes record data like this
I wrote the following script, which generates a SyntaxError : #!/usr/bin/python print Enter the
I would like to write a python script that takes a bunch of swf
I have a python script I wrote that I need to port to php.
I have a module in python, and based on the script that has called
I want to write a python script that takes 3 parameters. The first parameter
I have written a Python script that takes a 1.5 G XML file, parses
I wrote a script in python that scans a file and extract strings from

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.