-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_data.py
23 lines (17 loc) · 779 Bytes
/
upload_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pymongo.mongo_client import MongoClient
import pandas as pd
import json
# uniform resource indentifier
uri = "mongodb+srv://SINGHxTUSHAR:[email protected]/?retryWrites=true&w=majority"
# Create a new client and connect to the server
client = MongoClient(uri)
# create database name and collection name
DATABASE_NAME="Sensor-Fault-Detection"
COLLECTION_NAME="waferfault"
# read the data as a dataframe
df=pd.read_csv(r"C:\Users\dell\Desktop\Sensor Fault Detection\notebooks\notebooks\wafer_23012020_041211.csv.csv")
df=df.drop("Unnamed: 0",axis=1)
# Convert the data into json
json_record=list(json.loads(df.T.to_json()).values())
#now dump the data into the database
client[DATABASE_NAME][COLLECTION_NAME].insert_many(json_record)