Skip to content
Snippets Groups Projects
Commit 25ebfc42 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

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
No related tags found
1 merge request!179added file input control
Pipeline #7277 passed
# coding=utf-8
import os
import django
from django.conf import settings
......@@ -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
- Country
......@@ -310,7 +311,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
country.save()
# Location and Flying Team
# If no FT, then default location is CHL
# If no FT, then default location is CHL
ft = None
location = None
if not row['FLYING TEAM (FT)']:
......@@ -438,7 +439,7 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
for visit_date in set(visit_dates):
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
appointment_types = itembetter(
indexof(visit_date, visit_dates), appointmentTypes)
......@@ -461,7 +462,13 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
if __name__ == '__main__':
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 = df.fillna('').astype(unicode)
df.columns = [c.upper() for c in df.columns]
......@@ -471,7 +478,7 @@ if __name__ == '__main__':
df[column] = df[column].apply(function)
# get visits columns
regex = re.compile(r'\(V\d\)')
#
#
study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0]
#enable vouchers
study.columns.voucher_types = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment