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
9b9bf749
Commit
9b9bf749
authored
6 years ago
by
Carlos Vega
Committed by
Piotr Gawron
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added file input control
parent
c566f950
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
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 @
9b9bf749
# 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