Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
product-uniqer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
product-uniqer
Commits
1674051e
There was an error fetching the commit references. Please try again later.
Commit
1674051e
authored
4 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
bug fix: fucking python num conv error
parent
282f2433
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xlsx_conv.py
+15
-1
15 additions, 1 deletion
xlsx_conv.py
with
15 additions
and
1 deletion
xlsx_conv.py
+
15
−
1
View file @
1674051e
import
xlrd
import
csv
,
io
def
float_to_str
(
f
):
float_string
=
repr
(
f
)
if
'
e
'
in
float_string
:
# detect scientific notation
digits
,
exp
=
float_string
.
split
(
'
e
'
)
digits
=
digits
.
replace
(
'
.
'
,
''
).
replace
(
'
-
'
,
''
)
exp
=
int
(
exp
)
zero_padding
=
'
0
'
*
(
abs
(
int
(
exp
))
-
1
)
# minus 1 for decimal point in the sci notation
sign
=
'
-
'
if
f
<
0
else
''
if
exp
>
0
:
float_string
=
'
{}{}{}.0
'
.
format
(
sign
,
digits
,
zero_padding
)
else
:
float_string
=
'
{}0.{}{}
'
.
format
(
sign
,
zero_padding
,
digits
)
return
float_string
def
xlsx2csv
(
xlsxPath
,
sheetIndex
,
outputFd
):
wb
=
xlrd
.
open_workbook
(
xlsxPath
)
sh
=
wb
.
sheet_by_index
(
sheetIndex
)
...
...
@@ -8,7 +22,7 @@ def xlsx2csv(xlsxPath, sheetIndex, outputFd):
def
fuck_number_ele
(
ele
):
if
type
(
ele
)
is
float
:
s
=
str
(
ele
)
s
=
float_to_
str
(
ele
)
if
'
e
'
in
s
.
lower
():
raise
RuntimeError
(
'
Fuck python Float2Str: THIS IS A BUG. PLEASE REPORT.
'
)
if
s
.
endswith
(
'
.0
'
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment