From 792c170fd639827f6fcca3145e30797a11c70f2a Mon Sep 17 00:00:00 2001 From: quoije Date: Mon, 1 Apr 2024 12:52:27 -0400 Subject: [PATCH] first tsv commit --- {modules => db}/creds.env | 0 modules/app_db.py | 2 +- modules/app_tsv.py | 25 +++++++++++++++++++++++++ modules/db_notes.tsv | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) rename {modules => db}/creds.env (100%) diff --git a/modules/creds.env b/db/creds.env similarity index 100% rename from modules/creds.env rename to db/creds.env diff --git a/modules/app_db.py b/modules/app_db.py index 55ae9ef..2532991 100644 --- a/modules/app_db.py +++ b/modules/app_db.py @@ -2,7 +2,7 @@ from pymongo import MongoClient from dotenv import load_dotenv import os -load_dotenv("./creds.env") +load_dotenv("../db/creds.env") mUser = os.getenv() mPass = os.getenv() diff --git a/modules/app_tsv.py b/modules/app_tsv.py index e69de29..fb08fff 100644 --- a/modules/app_tsv.py +++ b/modules/app_tsv.py @@ -0,0 +1,25 @@ +import csv, os +import app_obd, app_car, app_account, app_gps +from datetime import datetime + +currentday = datetime.today().strftime("%d%m%Y") +currenttime = datetime.now().strftime("%H_%M_%S") +account = app_account.Account +car = app_car.Car +sCarModel = ''.join(letter for letter in car.model if letter.isalnum()) +tsv_name = account.name + "_" + sCarModel + "_" + currentday + "_" + currenttime + ".tsv" +tsv_path = "../db/tsv/" + tsv_name + +def tsv_writer(bExist): + with open(tsv_path, 'w') as o_file: + ## VN, NAME, DATE, TIME, GPS_X, GPS_Y, SPEED, ODOMETER + writer = csv.writer(o_file, delimiter='\t') + if bExist == False: + writer.writerow(["VN", "NAME", "DATE", "TIME", "GX", "GY", "SPEED", "ODO"]) + else: + writer.writerow([car.model, account.name, currentday, currenttime]) + +if os.path.exists(tsv_path): + tsv_writer(True) +else: + tsv_writer(False) \ No newline at end of file diff --git a/modules/db_notes.tsv b/modules/db_notes.tsv index 0fe5e1c..95df430 100644 --- a/modules/db_notes.tsv +++ b/modules/db_notes.tsv @@ -1,4 +1,4 @@ ## TSV File to MangoDB -## VN_20240401_00_00_00.TSV +## ACCOUNT_VN_20240401_00_00_00.TSV ## ## VN NAME, DATE, TIME, GPS_X, GPS_Y, SPEED, ODOMETER \ No newline at end of file