Commit 7866f744 authored by madhu.tr's avatar madhu.tr

task 2

parent 04176d2d
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (22)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/22.iml" filepath="$PROJECT_DIR$/.idea/22.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="a25e93a7-5a95-4848-9194-11f5189602bb" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="27VwTxHxJOnIcPzdNVfw433LKEZ" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\madhu.tr\PycharmProjects\pythonProject\22" />
</key>
</component>
<component name="RunManager" selected="Python.apii">
<configuration name="apii" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="22" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/apii.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="22" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="servicee" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="22" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/servicee.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.apii" />
<item itemvalue="Python.servicee" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="a25e93a7-5a95-4848-9194-11f5189602bb" name="Changes" comment="" />
<created>1649418572998</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1649418572998</updated>
</task>
<task id="LOCAL-00001" summary="task 2">
<created>1649424748160</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1649424748160</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="task 2" />
<option name="LAST_COMMIT_MESSAGE" value="task 2" />
</component>
</project>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
from starlette.responses import FileResponse
from servicee import monthlyhumiditydata
from fastapi import FastAPI
app = FastAPI()
@app.get("/getData1")
def monthlyhumiditydata1():
fpath,fname =monthlyhumiditydata()
return FileResponse(fpath,media_type='application/octet-stream',filename=fname)
\ No newline at end of file
#main
import pandas as pd
from datetime import datetime
epoch = datetime.strptime('2004-12-31 1:00:00', '%Y-%m-%d %H:%M:%S').timestamp()
print(epoch)
pd.options.display.max_rows = 99999
df = pd.read_csv("airrrr1-AirQualityUCI-_1_ - Worksheet.csv")
print(df.head(10))
print(df.Datetime)
print(df["Datetime"].values.tolist())
seconds = []
for j in df['Datetime'].values:
seconds.append(int(datetime.strptime(j, "%m/%d/%Y%H:%M:%S").timestamp()) * 1000)
print(seconds)
df['Datetime'] = seconds
print(df['Datetime'])
Banyio==3.5.0 Banyio==3.5.0
import pandas as pd
import requests
import json
import gzip
from main import df
import openpyxl
kairosdb_server = "http://192.168.0.220:8080"
url='http://192.168.0.220:8080/api/v1/datapoints/query'
# Simple test [without compression]
data = [
{
"name": "Madhu",
"datapoints": df[['Datetime', 'RH']].values.tolist(),
"tags": {"project": "table"}
}
]
response = requests.post(kairosdb_server + "/api/v1/datapoints", json.dumps(data))
print("Simple test [without compression]: \t %d (status code)" % response.status_code)
def minm(query):
if query=="months":
payload = json.dumps({
"metrics": [
{
"tags": {},
"name": "Madhu",
"aggregators": [
{
"name": "min",
"sampling": {
"value": "1",
"unit": "months"
}
}
]
}
],
"plugins": [],
"cache_time": 0,
"start_absolute":1094668200000,
"end_absolute":1126204200000
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.json()
def maxm(query):
if query=="months":
payload = json.dumps({
"metrics": [
{
"tags": {},
"name": "Madhu",
"aggregators": [
{
"name": "max",
"sampling": {
"value": "1",
"unit": "months"
}
}
]
}
],
"plugins": [],
"cache_time": 0,
"start_absolute":1094668200000,
"end_absolute":1126204200000
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.json()
def avgm(query):
if query=="months":
payload = json.dumps({
"metrics": [
{
"tags": {},
"name": "Madhu",
"aggregators": [
{
"name": "avg",
"sampling": {
"value": "1",
"unit": "months"
}
}
]
}
],
"plugins": [],
"cache_time": 0,
"start_absolute":1094668200000,
"end_absolute":1126204200000
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.json()
def monthlyhumiditydata():
hum2= maxm("months")['queries'][0]['results'][0]['values']
hum1= minm("months")['queries'][0]['results'][0]['values']
hum=avgm("months")['queries'][0]['results'][0]['values']
df1=pd.DataFrame(hum2,columns=["Updated_Date","maxm"])
df2=pd.DataFrame(hum1, columns=["Updated_Date", "minm"])
df3=pd.DataFrame(hum, columns=["Updated_Date", "avgm"])
a=pd.merge(df1,df2,on="Updated_Date")
b=pd.merge(a,df3,on="Updated_Date")
b.to_excel("scripts/Data/monthreport.xlsx")
fpath = 'scripts/Data/'
fname = 'monthreport.xlsx'
filepath = fpath + fname
return filepath, fname
\ No newline at end of file
Markdown is supported
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