def save_csv(file_path): data_base = DataBaseConnector() data_rows = data_base.output_meta_date() with open(file_path, 'w') as f: writer = csv.writer(f) writer.writerow(COLUMN_NAME) writer.writerows(data_rows) return 0
def output_meta_date(): data_base = DataBaseConnector() output_data = data_base.output_meta_date() for row in output_data: if row["name"] is None: row["long_name"] = 0 elif len(row["name"]) >= NAME_THRESH: row["long_name"] = 1 else: row["long_name"] = 0 return output_data
def insert_date(self): title = self.file_name pedestrian = int(request.form["pedestrian_num"]) bicycle = int(request.form["bicycle_num"]) motorbike = int(request.form["motorbike_num"]) passenger_car = int(request.form["passenger_car_num"]) small_freight_car = int(request.form["small_freight_car_num"]) bus = int(request.form["bus_num"]) ordinary_freight_car = int(request.form["ordinary_freight_car_num"]) data_base = DataBaseConnector() data_base.add_row(title, pedestrian, bicycle, motorbike, passenger_car, small_freight_car, bus, ordinary_freight_car)
def save_csv(): f = StringIO() data_base = DataBaseConnector() data_rows = data_base.output_meta_date() output_keys = COLUMN_NAME output_values = [] for row in data_rows: output_values.append(list(row.values())) writer = csv.writer(f, quotechar='"', quoting=csv.QUOTE_ALL, lineterminator="\n") writer.writerow(output_keys) writer.writerows(output_values) res = make_response() res.data = f.getvalue() res.headers["Content-Type"] = "text/csv" res.headers["Content-Disposition"] = "attachment; filename=traffic.csv" return res
def init_table(): data_base = DataBaseConnector() data_base.delete_rows() return data_base.output_meta_date()
def output_meta_date(): data_base = DataBaseConnector() return data_base.output_meta_date()