Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
ef0aebc7
authored
2021-01-26 16:18:25 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix / -> 7
1 parent
eafa702d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletions
src/apps/doc/ocr/wb.py
src/apps/doc/ocr/wb.py
View file @
ef0aebc
...
...
@@ -2,6 +2,7 @@ import re
import
random
import
locale
import
numpy
as
np
from
datetime
import
datetime
from
pandas._libs
import
tslib
from
pandas._libs.tslibs.nattype
import
NaTType
from
pandas.core.indexes.datetimes
import
DatetimeIndex
...
...
@@ -255,7 +256,7 @@ class BSWorkbook(Workbook):
date_col
=
date_col
+
1
for
date_tuple_src
in
ws
.
iter_cols
(
min_col
=
date_col
,
max_col
=
date_col
,
min_row
=
min_row
,
values_only
=
True
):
date_tuple
=
[
date
[:
10
]
if
isinstance
(
date
,
str
)
else
date
for
date
in
date_tuple_src
]
dt_array
,
tz_parsed
=
tslib
.
array_to_datetime
(
dt_array
,
_
=
tslib
.
array_to_datetime
(
np
.
array
(
date_tuple
,
copy
=
False
,
dtype
=
np
.
object_
),
errors
=
"coerce"
,
utc
=
False
,
...
...
@@ -265,6 +266,22 @@ class BSWorkbook(Workbook):
)
dti
=
DatetimeIndex
(
dt_array
,
tz
=
None
,
name
=
None
)
rebuid
=
False
for
idx
,
d
in
enumerate
(
dti
):
try
:
if
isinstance
(
d
,
NaTType
)
and
isinstance
(
date_tuple
[
idx
],
str
):
match_obj
=
re
.
match
(
r'(\d{4})[7/](\d{2})[7/](\d{2})'
,
date_tuple
[
idx
])
if
match_obj
:
dt_array
[
idx
]
=
np
.
datetime64
(
datetime
(
int
(
match_obj
.
group
(
1
)),
int
(
match_obj
.
group
(
2
)),
int
(
match_obj
.
group
(
3
))))
rebuid
=
True
except
Exception
as
e
:
continue
if
rebuid
:
dti
=
DatetimeIndex
(
dt_array
,
tz
=
None
,
name
=
None
)
month_list
,
idx_list
=
self
.
month_split
(
dti
,
date_list
,
date_statistics
)
if
len
(
month_list
)
==
0
:
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment