Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Biometris
MCRA.DataConversionTools
Commits
300c25dd
Commit
300c25dd
authored
Mar 26, 2020
by
Hans van den Heuvel
Browse files
Conforming to Python style again
parent
ad32c584
Changes
2
Hide whitespace changes
Inline
Side-by-side
Convert-EUProcessingFactorsDB/Convert-EUProcessingFactorsDB.py
View file @
300c25dd
...
...
@@ -40,7 +40,7 @@ dataset.add(
name
=
'processing_type'
,
short_argument
=
'-t'
,
help
=
'The (input) processing type file - '
+
'format: csv (Comma Seperated).'
,
+
'format: csv (Comma Seperated).'
,
default_name
=
'ProcessingTypes.csv'
,
default_dir
=
'Input'
,
direction
=
'Input'
)
...
...
@@ -124,11 +124,11 @@ dataset.verbose(1, 'Input file : {file}; {version}; {props}'.format(
# Use this file only if called explictly from command line
# and of course, it has to exist. The -g is enough to trigger the default
if
dataset
.
args
.
food_composition_file
is
not
None
\
and
dataset
.
food_composition
.
file
.
exist
:
and
dataset
.
food_composition
.
file
.
exist
:
dataset
.
food_composition
.
load
(
sheet_name
=
'FoodTranslation'
)
dataset
.
verbose
(
1
,
'Input file : {file}; {props}'
.
format
(
file
=
dataset
.
food_composition
.
file
.
path
,
props
=
dataset
.
food_composition
.
properties
))
file
=
dataset
.
food_composition
.
file
.
path
,
props
=
dataset
.
food_composition
.
properties
))
#############################################################################
...
...
@@ -232,11 +232,11 @@ if dataset.food_composition.sheet is not None:
fcs
=
dataset
.
food_composition
.
sheet
[
dataset
.
food_composition
.
sheet
[
'idToFood'
].
str
.
startswith
(
'P'
)]
# Now split the first column
fs
=
pd
.
DataFrame
()
fs
=
pd
.
DataFrame
()
# Bit of a mess, to combine again.
fs
[[
'idFromFood-Left'
,
'idFromFood-Right'
]]
=
\
fcs
[
'idFromFood'
].
str
.
rsplit
(
'-'
,
n
=
1
,
expand
=
True
)
fcs
=
fcs
.
merge
(
fs
,
left_index
=
True
,
right_index
=
True
)
fcs
=
fcs
.
merge
(
fs
,
left_index
=
True
,
right_index
=
True
)
# New columns is properly joined now
fcs
[
'idToFood-PC'
]
=
fcs
.
loc
[:,
(
'idToFood'
,
'idFromFood-Right'
)].
apply
(
lambda
x
:
'-'
.
join
(
x
.
dropna
()),
axis
=
1
)
...
...
@@ -249,7 +249,7 @@ if dataset.food_composition.sheet is not None:
efsa_combined
.
loc
[
(
efsa_combined
[
'idToFood-PC'
].
notna
()),
'idFoodProcessed'
]
=
efsa_combined
[
'idFromFood'
]
print
(
fcs
)
#############################################################################
# Phase 3. Exporting the data.
# Seems obvious what to do here.
...
...
Convert-EUProcessingFactorsDB/mcra.py
View file @
300c25dd
...
...
@@ -186,7 +186,7 @@ class DataSheet:
' * Modified: {mod}'
.
format
(
mod
=
self
.
file
.
modified
))
self
.
add_reportline
(
' * File size: {size_str} ({size} B)'
.
format
(
size_str
=
self
.
file
.
size_string
,
size
=
self
.
file
.
size
))
size_str
=
self
.
file
.
size_string
,
size
=
self
.
file
.
size
))
self
.
add_reportline
(
' * Hash: {hash})'
.
format
(
hash
=
self
.
file
.
hash
))
self
.
report
=
self
.
report
+
temp
...
...
@@ -320,12 +320,11 @@ class DataSheet:
if
self
.
file
.
extension
==
'.zip'
:
if
to
is
None
:
shutil
.
copyfile
(
path
,
os
.
path
.
join
(
self
.
file
.
zippath
,
os
.
path
.
split
(
path
)[
1
]))
os
.
path
.
join
(
self
.
file
.
zippath
,
os
.
path
.
split
(
path
)[
1
]))
else
:
shutil
.
copyfile
(
path
,
os
.
path
.
join
(
self
.
file
.
zippath
,
to
))
os
.
path
.
join
(
self
.
file
.
zippath
,
to
))
class
DataSet
:
...
...
@@ -456,17 +455,19 @@ class DataSet:
#
if
dataset
.
autoload
:
if
getattr
(
self
.
args
,
datasetname
+
'_file'
)
is
None
\
and
not
dataset
.
file
.
necessary
:
and
not
dataset
.
file
.
necessary
:
# Don't load files which are not necessary and not
# explictly called from command line.
self
.
verbose
(
3
,
'Not loading {file}.'
.
format
(
file
=
dataset
.
file
.
path
))
self
.
verbose
(
3
,
'Not loading {file}.'
.
format
(
file
=
dataset
.
file
.
path
))
else
:
dataset
.
load
()
if
dataset
.
file
.
exist
:
self
.
verbose
(
1
,
'Input file : {file}; {props}'
.
format
(
file
=
dataset
.
file
.
path
,
props
=
dataset
.
properties
))
self
.
verbose
(
1
,
'Input file : {file}; {props}'
.
format
(
file
=
dataset
.
file
.
path
,
props
=
dataset
.
properties
))
# High verbosity, dump data.
self
.
verbose
(
3
,
dataset
.
sheet
)
else
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment