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
5090e388
There was an error fetching the commit references. Please try again later.
Commit
5090e388
authored
5 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
allow PROG ALPHA open xlsx and csv
parent
542cdb7d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
main.py
+2
-3
2 additions, 3 deletions
main.py
summerize-part-list/beta2alpha.py
+1
-2
1 addition, 2 deletions
summerize-part-list/beta2alpha.py
utils.py
+1
-0
1 addition, 0 deletions
utils.py
xlsx_conv.py
+22
-0
22 additions, 0 deletions
xlsx_conv.py
with
26 additions
and
5 deletions
main.py
+
2
−
3
View file @
5090e388
...
...
@@ -14,7 +14,7 @@ if os.name == 'nt':
from
uniqer
import
*
from
utils
import
*
import
material
import
csv_preprocess
import
csv_preprocess
,
xlsx_conv
import
numpy
as
np
from
io
import
StringIO
...
...
@@ -36,8 +36,7 @@ def _main():
junk_material_words
=
[
'
(厚)
'
,
'
(宽)
'
,
'
(单件重)
'
]
junk_part_words
=
[]
with
open
(
fname
,
mode
=
'
r
'
)
as
fd
:
fcontent
=
fd
.
read
()
fcontent
=
xlsx_conv
.
read_as_csv
(
fname
)
fcontent
=
csv_preprocess
.
clean_csv
(
fcontent
)
fcontent
=
csv_preprocess
.
clean_csv_2
(
fcontent
)
...
...
This diff is collapsed.
Click to expand it.
summerize-part-list/beta2alpha.py
+
1
−
2
View file @
5090e388
...
...
@@ -31,8 +31,7 @@ def execute_program_alpha(mypath, parent_arg1):
print
(
'
EXEC =======================>
'
,
args
)
ret
=
subprocess
.
run
(
args
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
for
line
in
ret
.
stdout
:
print
(
line
)
print
(
ret
.
stdout
)
if
ret
.
returncode
!=
0
:
raise
RuntimeError
(
'
SubProcess returned in status
'
+
str
(
ret
.
returncode
))
print
(
'
EXEC SUBPROC EXITED =======================>
'
)
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
1
−
0
View file @
5090e388
...
...
@@ -55,3 +55,4 @@ def try_copy(file_path, out_dir, dst = None):
shutil
.
copy
(
file_path
,
os
.
path
.
join
(
out_dir
,
name
))
This diff is collapsed.
Click to expand it.
summerize-part-list/
xlsx_conv.py
→
xlsx_conv.py
+
22
−
0
View file @
5090e388
import
xlrd
import
csv
import
config
import
csv
,
io
def
xlsx2csv
(
xlsxPath
,
sheetIndex
,
outputFd
):
wb
=
xlrd
.
open_workbook
(
xlsxPath
)
...
...
@@ -10,4 +9,14 @@ def xlsx2csv(xlsxPath, sheetIndex, outputFd):
for
rownum
in
range
(
sh
.
nrows
):
wr
.
writerow
(
sh
.
row_values
(
rownum
))
def
read_as_csv
(
fname
):
is_xlsx
=
lambda
fname
:
fname
.
endswith
(
'
.xlsm
'
)
or
fname
.
endswith
(
'
.xlsx
'
)
or
fname
.
endswith
(
'
.xls
'
)
or
fname
.
endswith
(
'
.XLSM
'
)
or
fname
.
endswith
(
'
.XLSX
'
)
or
fname
.
endswith
(
'
.XLS
'
)
# read xlsx or csv
if
is_xlsx
(
fname
):
buf
=
io
.
StringIO
()
xlsx2csv
(
fname
,
0
,
buf
)
return
buf
.
getvalue
()
else
:
with
open
(
fname
,
mode
=
'
r
'
)
as
fd
:
return
fd
.
read
()
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