NCVotes / voters-ingestor

Django app to create and configure Postgres DB, then fetch and process public voter registration and voter history files from N.C. Board of Elections
MIT License
10 stars 1 forks source link

time data '10/01/1984' does not match format '%Y-%m-%d' #10

Open bmrankin opened 6 years ago

bmrankin commented 6 years ago

Running python manage.py voter_process

Encountered error:

Processing NCVoter file...
Processing change tracking for file downloads/ncvoter/2018-03-06T14:06:51:1520345211/ncvoter_Statewide.txt
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/bryanrankin/projects/python/nc-votes/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/Users/bryanrankin/projects/python/nc-votes/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/bryanrankin/projects/python/nc-votes/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/bryanrankin/projects/python/nc-votes/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/Users/bryanrankin/projects/python/nc-votes/voter/management/commands/voter_process.py", line 273, in handle
    process_files(output=True, county_num=county_num, initial=initial)
  File "/Users/bryanrankin/projects/python/nc-votes/voter/management/commands/voter_process.py", line 207, in process_files
    added, modified, ignored = create_changes(output, initial, file_tracker)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/Users/bryanrankin/projects/python/nc-votes/voter/management/commands/voter_process.py", line 93, in create_changes
    parsed_row = model_class.parse_row(row)
  File "/Users/bryanrankin/projects/python/nc-votes/voter/models.py", line 124, in parse_row
    registr_dt = datetime.strptime(registr_dt_str, '%Y-%m-%d')
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_strptime.py", line 362, in _strptime
    (data_string, format))
ValueError: time data '10/01/1984' does not match format '%Y-%m-%d'

It does look like the dates in the data are %m-%d-%Y. Is there a function that converts these.

Thanks for the help.