Commcare-export tool error

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

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

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?

··· On 20 June 2016 at 21:05, wrote:

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

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

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Simon Kelly
Senior Engineer | Dimagi South Africa

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 574-631-3656 | jolson6@nd.edu

On Thu, Jun 23, 2016 at 5:28 AM, Simon Kelly skelly@dimagi.com wrote:

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?

On 20 June 2016 at 21:05, jolson6@nd.edu wrote:

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

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

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Simon Kelly
Senior Engineer | Dimagi South Africa

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No problem and glad you were able to figure it out.

··· On 24 June 2016 at 19:48, Jared Olson wrote:

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
574-631-3656 | jolson6@nd.edu

On Thu, Jun 23, 2016 at 5:28 AM, Simon Kelly skelly@dimagi.com wrote:

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?

On 20 June 2016 at 21:05, jolson6@nd.edu wrote:

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

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

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Simon Kelly
Senior Engineer | Dimagi South Africa

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Simon Kelly
Senior Engineer | Dimagi South Africa