Esempio n. 1
0
def parse(string, agnostic=False, **kwargs):
    parsed = _parse(string, **kwargs)
    if agnostic or (parsed == _parse(string, yearfirst=True, **kwargs)
                           == _parse(string, dayfirst=True, **kwargs)):
        return parsed
    else:
        raise ValueError("The date was ambiguous: %s" % string)
Esempio n. 2
0
def parse(string, agnostic=False, **kwargs):
    parsed = _parse(string, **kwargs)
    if agnostic or (parsed == _parse(string, yearfirst=True, **kwargs) ==
                    _parse(string, dayfirst=True, **kwargs)):
        return parsed
    else:
        raise ValueError("The date was ambiguous: %s" % string)
Esempio n. 3
0
def parse(val):
    from dateutil.parser import parse as _parse
    from django.conf import settings

    if settings.USE_TZ:
        return _parse(val)
    return _parse(val).replace(tzinfo=None)
def ReadFilesToDF(files, delim=None):
    """
	ReadFilesToDF is a helper routine that takes the nominal dataframes (can be singletons)
	labels data index according to any found date index , or monotonically increasing sequence
	"""
    allR = []
    for indexa, elem in enumerate(files):
        try:
            c0 = _read_csv(elem,
                           error_bad_lines=False,
                           header=None,
                           delimiter=delim,
                           engine='python')
        except _EmptyDataError as err:
            c0 = _DataFrame()
            c0[0] = [0]
        try:
            c0['date'] = _parse(elem, fuzzy=True)
        except ValueError as err:
            dateFound = FindDate(elem)
            if len(dateFound) == 0:
                c0['date'] = indexa
            else:
                c0['date'] = dateFound[0]
        allR.append(c0)
    merged = _concat(allR, ignore_index=True)
    merged.index = merged['date']
    return allR, merged
Esempio n. 5
0
def _valiDate(date_text):
    if not date_text == '':
        try:
            date = _parse(date_text)
            return str(date.date())
        except ValueError:
            raise ValueError("Incorrect data format, should be YYYY-MM-DD or MM-DD-YYYY")
    else: pass
Esempio n. 6
0
def _valiDate(date_text):
    if date_text == '':
        return date_text
    else:
        try:
            date = _parse(date_text)
            return str(date.date())
        except ValueError:
            raise ValueError(
                "Incorrect data format, should be YYYY-MM-DD or MM-DD-YYYY")
Esempio n. 7
0
 def _get_records(parser):
     return list(parser._parse())
Esempio n. 8
0
def parse(string, agnostic=False, **kwargs):
    return _parse(string, yearfirst=True, dayfirst=False, **kwargs)
Esempio n. 9
0
def parse(string: str) -> datetime:
    return _parse(string, tzinfos={None: perth})
Esempio n. 10
0
def parse(string, agnostic=False, **kwargs):
    return _parse(string, yearfirst=True, dayfirst=False, **kwargs)