Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
25ebfc42
Commit
25ebfc42
authored
6 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/import_file' into 'master'
added file input control See merge request NCER-PD/scheduling-system!179
parents
c566f950
9b9bf749
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!179
added file input control
Pipeline
#7277
passed
6 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/import_file.py
+12
-5
12 additions, 5 deletions
smash/import_file.py
with
12 additions
and
5 deletions
smash/import_file.py
+
12
−
5
View file @
25ebfc42
# coding=utf-8
import
os
import
os
import
django
import
django
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -37,7 +38,7 @@ def indexof(element, l):
...
@@ -37,7 +38,7 @@ def indexof(element, l):
'''
'''
#
Things that *could* already be on the database:
#
Things that *could* already be on the database:
- Language
- Language
- Country
- Country
...
@@ -310,7 +311,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
...
@@ -310,7 +311,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
country
.
save
()
country
.
save
()
# Location and Flying Team
# Location and Flying Team
#
If no FT, then default location is CHL
#
If no FT, then default location is CHL
ft
=
None
ft
=
None
location
=
None
location
=
None
if
not
row
[
'
FLYING TEAM (FT)
'
]:
if
not
row
[
'
FLYING TEAM (FT)
'
]:
...
@@ -438,7 +439,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
...
@@ -438,7 +439,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
for
visit_date
in
set
(
visit_dates
):
for
visit_date
in
set
(
visit_dates
):
datetime_when
=
visit_date
.
strftime
(
'
%Y-%m-%d
'
)
datetime_when
=
visit_date
.
strftime
(
'
%Y-%m-%d
'
)
#
get the indices of each occurrence of the date and use them to get
#
get the indices of each occurrence of the date and use them to get
# the appointment types
# the appointment types
appointment_types
=
itembetter
(
appointment_types
=
itembetter
(
indexof
(
visit_date
,
visit_dates
),
appointmentTypes
)
indexof
(
visit_date
,
visit_dates
),
appointmentTypes
)
...
@@ -461,7 +462,13 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
...
@@ -461,7 +462,13 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
file
=
'
/Users/carlos.vega/ownCloud/Documents/Projects/PDP/copy.xlsx
'
if
len
(
sys
.
argv
)
<
2
:
logging
.
warn
(
'
Please, execute the program as: python {} file_path.xlsx
'
.
format
(
sys
.
argv
[
0
]))
sys
.
exit
(
1
)
file
=
sys
.
argv
[
1
]
if
not
os
.
path
.
isfile
(
file
):
logging
.
warn
(
'
Please, execute the program with a valid file path.
'
)
sys
.
exit
(
1
)
df
=
pd
.
read_excel
(
file
,
dtype
=
object
)
df
=
pd
.
read_excel
(
file
,
dtype
=
object
)
df
=
df
.
fillna
(
''
).
astype
(
unicode
)
df
=
df
.
fillna
(
''
).
astype
(
unicode
)
df
.
columns
=
[
c
.
upper
()
for
c
in
df
.
columns
]
df
.
columns
=
[
c
.
upper
()
for
c
in
df
.
columns
]
...
@@ -471,7 +478,7 @@ if __name__ == '__main__':
...
@@ -471,7 +478,7 @@ if __name__ == '__main__':
df
[
column
]
=
df
[
column
].
apply
(
function
)
df
[
column
]
=
df
[
column
].
apply
(
function
)
# get visits columns
# get visits columns
regex
=
re
.
compile
(
r
'
\(V\d\)
'
)
regex
=
re
.
compile
(
r
'
\(V\d\)
'
)
#
#
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
#enable vouchers
#enable vouchers
study
.
columns
.
voucher_types
=
True
study
.
columns
.
voucher_types
=
True
...
...
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