commcare-export tool error

21 views
Skip to first unread message

jol...@nd.edu

unread,
Jun 20, 2016, 3:05:46 PM6/20/16
to commcare-users

Hi there. I'm using the commcare-export tool to retrieve my form and case data from CommCare HQ. I use the str2date function in many of my query sheets. I'm getting a ValueError when using this function on the date_closed metadata field. I'm guessing this is because none of my subject cases have been closed yet. I've pasted the Traceback below. Perhaps there is a way to modify the str2date function to check for empty cells so that it won't throw the ValueError. Thanks.


Traceback (most recent call last):

  File ".../bin/commcare-export", line 11, in <module>

    sys.exit(entry_point())

  File ".../lib/python2.7/site-packages/commcare_export/cli.py", line 197, in entry_point

    main(sys.argv[1:])

  File ".../lib/python2.7/site-packages/commcare_export/cli.py", line 83, in main

    main_with_args(args)

  File ".../lib/python2.7/site-packages/commcare_export/cli.py", line 182, in main_with_args

    writer.write_table(table)

  File ".../lib/python2.7/site-packages/commcare_export/writers.py", line 381, in write_table

    for row in table['rows']:

  File ".../lib/python2.7/site-packages/commcare_export/minilinq.py", line 256, in iterate

    yield self.body.eval(env.replace(item)) 

  File ".../lib/python2.7/site-packages/commcare_export/minilinq.py", line 214, in eval

    return [item.eval(env) for item in self.items]

  File ".../lib/python2.7/site-packages/commcare_export/minilinq.py", line 342, in eval

    return fn_result(*args_results)

  File ".../lib/python2.7/site-packages/commcare_export/misc.py", line 39, in _inner

    return fn(*([val] if len(args) == 1 else [args[0], val]))

  File ".../lib/python2.7/site-packages/commcare_export/env.py", line 245, in str2date

    date = parser.parse(val)

  File ".../lib/python2.7/site-packages/dateutil/parser.py", line 1164, in parse

    return DEFAULTPARSER.parse(timestr, **kwargs)

  File ".../lib/python2.7/site-packages/dateutil/parser.py", line 574, in parse

    if cday > monthrange(cyear, cmonth)[1]:

  File ".../python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py", line 121, in monthrange

    day1 = weekday(year, month, 1)

  File ".../python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py", line 113, in weekday

    return datetime.date(year, month, day).weekday()

ValueError: year is out of range

Simon Kelly

unread,
Jun 23, 2016, 5:28:52 AM6/23/16
to commcar...@googlegroups.com
Hi 

Thanks for reporting this issue. There is already some checking for empty values before attempting to convert them to dates. If you remove the 'str2date' conversion on that field what are the values that get output? 

--
You received this message because you are subscribed to the Google Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Simon Kelly
Senior Engineer | Dimagi South Africa

Jared Olson

unread,
Jun 24, 2016, 1:48:04 PM6/24/16
to commcar...@googlegroups.com
Hi Simon,

I ended up getting it figured out. At some point one of the Excel files we uploaded to bulk import cases had a glitch and converted all of the dates to numbers. So we had a number of subject cases that had numbers for dates, which is why the str2date function was complaining. Sorry for any confusion. Thanks for you help.


--
Jared M. Olson
Associate Research Programmer
Center for Research Computing | University of Notre Dame

--
You received this message because you are subscribed to a topic in the Google Groups "commcare-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/commcare-users/QmdWUt0cibI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to commcare-user...@googlegroups.com.

Simon Kelly

unread,
Jun 27, 2016, 8:37:37 AM6/27/16
to commcar...@googlegroups.com
No problem and glad you were able to figure it out.
Reply all
Reply to author
Forward
0 new messages