Skip to content

Commit 3063a48

Browse files
committed
🔥 remove useless code as it is now handled in pyexcel-io
1 parent b50ec1d commit 3063a48

File tree

2 files changed

+5
-58
lines changed

2 files changed

+5
-58
lines changed

pyexcel_htmlr/htmlr.py

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
:copyright: (c) 2015-2017 by Onni Software Ltd & its contributors
77
:license: New BSD License
88
"""
9-
import re
10-
119
import html5lib
1210
import xml.etree.ElementTree as etree
1311

14-
import datetime
1512
from pyexcel_io.book import BookReader
1613
from pyexcel_io.sheet import SheetReader, NamedContent
1714
from pyexcel_io._compact import OrderedDict
15+
import pyexcel_io.service as service
1816

1917

2018
ALL_TABLE_COLUMNS = './/*[name()="td" or name()="th"]'
@@ -82,17 +80,17 @@ def column_iterator(self, row):
8280
def __convert_cell(self, cell_text):
8381
ret = None
8482
if self.__auto_detect_int:
85-
ret = _detect_int_value(cell_text)
83+
ret = service.detect_int_value(cell_text)
8684
if ret is None and self.__auto_detect_float:
87-
ret = _detect_float_value(cell_text)
85+
ret = service.detect_float_value(cell_text)
8886
shall_we_ignore_the_conversion = (
8987
(ret in [float('inf'), float('-inf')]) and
9088
self.__ignore_infinity
9189
)
9290
if shall_we_ignore_the_conversion:
9391
ret = None
9492
if ret is None and self.__auto_detect_datetime:
95-
ret = _detect_date_value(cell_text)
93+
ret = service.detect_date_value(cell_text)
9694
if ret is None:
9795
ret = cell_text
9896
return ret
@@ -145,58 +143,6 @@ def fromstring(s):
145143
return p.parse(s)
146144

147145

148-
def _detect_date_value(csv_cell_text):
149-
"""
150-
Read the date formats that were written by csv.writer
151-
"""
152-
ret = None
153-
try:
154-
if len(csv_cell_text) == 10:
155-
ret = datetime.datetime.strptime(
156-
csv_cell_text,
157-
"%Y-%m-%d")
158-
ret = ret.date()
159-
elif len(csv_cell_text) == 19:
160-
ret = datetime.datetime.strptime(
161-
csv_cell_text,
162-
"%Y-%m-%d %H:%M:%S")
163-
elif len(csv_cell_text) > 19:
164-
ret = datetime.datetime.strptime(
165-
csv_cell_text[0:26],
166-
"%Y-%m-%d %H:%M:%S.%f")
167-
except ValueError:
168-
pass
169-
return ret
170-
171-
172-
def _detect_float_value(csv_cell_text):
173-
try:
174-
should_we_skip_it = (csv_cell_text.startswith('0') and
175-
csv_cell_text.startswith('0.') is False)
176-
if should_we_skip_it:
177-
# do not convert if a number starts with 0
178-
# e.g. 014325
179-
return None
180-
else:
181-
return float(csv_cell_text)
182-
except ValueError:
183-
return None
184-
185-
186-
def _detect_int_value(csv_cell_text):
187-
if csv_cell_text.startswith('0') and len(csv_cell_text) > 1:
188-
return None
189-
try:
190-
return int(csv_cell_text)
191-
except ValueError:
192-
pattern = '([0-9]+,)*[0-9]+$'
193-
if re.match(pattern, csv_cell_text):
194-
integer_string = csv_cell_text.replace(',', '')
195-
return int(integer_string)
196-
else:
197-
return None
198-
199-
200146
def text_from_element(elem):
201147
builder = []
202148
for x in elem.iter():

rnd_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/pyexcel/pyexcel-io/archive/dev.zip

0 commit comments

Comments
 (0)