Commit 205fff60 authored by Christine Plumejeaud's avatar Christine Plumejeaud
Browse files

Set the path to CSV data files using os

parent df96dd9a
...@@ -18,12 +18,15 @@ import numpy as np ...@@ -18,12 +18,15 @@ import numpy as np
import csv import csv
import json import json
import io import io
import os
#import flask_ext #import flask_ext
#import flask_excel as excel #import flask_excel as excel
#import pyexcel as pe #import pyexcel as pe
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) # refers to application_top
APP_STATIC = os.path.join(APP_ROOT, 'static')
APP_DATA = os.path.join(APP_STATIC, 'data')
app = Flask(__name__) app = Flask(__name__)
CORS(app) CORS(app)
...@@ -91,7 +94,8 @@ def formatOutput(dfcsv): ...@@ -91,7 +94,8 @@ def formatOutput(dfcsv):
#print('shortenfields ? '+shortenfields) #print('shortenfields ? '+shortenfields)
if (shortenfields != None and shortenfields=='true') : if (shortenfields != None and shortenfields=='true') :
#API;colname;short_colname #API;colname;short_colname
mapnames = pd.read_csv('static/data/shorten_names.csv', sep = ';') filename = os.path.join(APP_DATA, 'shorten_names.csv')
mapnames = pd.read_csv(filename, sep = ';')
#Filter according API #Filter according API
mapnames = mapnames[mapnames['API']=='pointcalls'] mapnames = mapnames[mapnames['API']=='pointcalls']
#print(mapnames['colname']) #print(mapnames['colname'])
...@@ -118,8 +122,8 @@ def getPointcalls(): ...@@ -118,8 +122,8 @@ def getPointcalls():
""" """
import pandas as pd import pandas as pd
path = '/var/www/html/data/' filename = os.path.join(APP_DATA, 'pointcalls_API_11mai2020.csv')
dfcsv = pd.read_csv('static/data/pointcalls_API_11mai2020.csv', sep = ';') dfcsv = pd.read_csv(filename, sep = ';')
#https://stackoverflow.com/questions/24251219/pandas-read-csv-low-memory-and-dtype-options #https://stackoverflow.com/questions/24251219/pandas-read-csv-low-memory-and-dtype-options
#pd.read_csv('static/data/pointcalls_API_11mai2020.csv', dtype={"all_cargos": object, "pkid": int}) #pd.read_csv('static/data/pointcalls_API_11mai2020.csv', dtype={"all_cargos": object, "pkid": int})
#print(dfcsv.columns) #print(dfcsv.columns)
...@@ -150,8 +154,8 @@ def getTravels(): ...@@ -150,8 +154,8 @@ def getTravels():
""" """
import pandas as pd import pandas as pd
path = '/var/www/html/data/' filename = os.path.join(APP_DATA, 'travels_API_11mai2020.csv')
dfcsv = pd.read_csv('static/data/travels_API_11mai2020.csv', sep = ';') dfcsv = pd.read_csv(filename, sep = ';')
## Filter the result according requested params ## Filter the result according requested params
params = request.args.get("params") params = request.args.get("params")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment