Commit dd0ea154 by mohammed.shibili

sender first commit

parents
# Default ignored files
/shelf/
/workspace.xml
Task3.xlsx
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N801" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ 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.9 (mqtt)" 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/mqtt.iml" filepath="$PROJECT_DIR$/.idea/mqtt.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<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="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
import uvicorn
if __name__ == "__main__":
uvicorn.run("script.service.main:app", port=8000, reload=True)
\ No newline at end of file
[log]
path=temp/Task3.csv
host_name=192.168.0.220
\ No newline at end of file
import configparser
config = configparser.RawConfigParser()
config.read("conf/paths.conf")
csv_path = config.get("log", "path")
host_name = config.get("log", "host_name")
import json
def convert_json(data_frame):
json_dict = data_frame.to_dict(orient="records")
json_data = json.dumps(json_dict, indent=4)
return json_data
import pandas as pd
from script.config.appconf import csv_path
dataset = pd.read_csv(csv_path)
def read_csv():
try:
new_dataframe = pd.DataFrame()
new_dataframe = pd.concat([new_dataframe, dataset.head(10)], ignore_index=True)
new_dataframe = pd.concat([new_dataframe, dataset.tail(10)], ignore_index=True)
return new_dataframe
except Exception as e:
print("file not reading", e)
from script.config.appconf import host_name
from script.core.handlers.convert_tojson import convert_json
from script.core.handlers.read_csv import read_csv
from fastapi import FastAPI
import paho.mqtt.client as mqtt
app = FastAPI()
data_frame = read_csv()
json_data = convert_json(data_frame)
@app.post("/send")
async def json_listner():
client = mqtt.Client()
client.connect(host_name, 1883)
client.publish("json_data", json_data)
return "json file send"
This diff is collapsed. Click to expand it.
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