Created
September 2, 2015 04:50
-
-
Save danabauer/24b199970f570cb48819 to your computer and use it in GitHub Desktop.
parsing dates in open source program csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| import csv | |
| if __name__ == '__main__': | |
| from_raw = raw_input('\nEnter FROM Date (e.g. 2013-11-29) :') | |
| from_date = datetime.date(*map(int, from_raw.split('-'))) | |
| print 'From date: = ' + str(from_date) | |
| to_raw = raw_input('\nEnter TO Date (e.g. 2013-11-30) :') | |
| to_date = datetime.date(*map(int, to_raw.split('-'))) | |
| in_file = 'Opensrc_disc_signups_11-10-14.csv' | |
| for line in in_file: | |
| fields = line.split(',') | |
| #found_date = datetime.date(*map(int, fields[0].split(' ')[0].split('-'))) | |
| found_date = datetime.datetime.strptime(fields[0], "%d-%b-%Y" ) | |
| if from_date <= found_date <= to_date: | |
| print line | |
| in_file.close() | |
| # The oss program dates are in this format 06-OCT-2014 %d-%b-$Y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment