#-*- coding: utf-8 -*-
import time
import pymongo
import numpy as np
import pandas as pd
from datetime import datetime, timedelta
from configparser import ConfigParser
from tabulate import tabulate
def print_df(df):
print(tabulate(df, headers='keys', tablefmt='psql'))
def getMongoData(mongoCon):
bList = []
try:
mList = mongoCon.CL_DEVICE_INFO.aggregate([ ])
except Exception as err:
print (err)
for m in mList:
bList.append(m)
return bList
try:
mongoCon = pymongo.MongoClient('127.0.0.1', 27017).rtls
except Exception as err:
print('[MongoDB] Connection Error')
try:
dataList = getMongoData(mongoCon)
dataDf = pd.DataFrame(dataList)
print_df(dataDf)
dataDf.to_csv("C:\\test\\beacon.csv", mode='w')
except Exception as err:
print('getMongoData Error')