Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mongo_aggregate
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ajil.k
mongo_aggregate
Commits
e035cbd7
Commit
e035cbd7
authored
Jan 31, 2023
by
ajil.k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updateded
parent
f05403dc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
0 deletions
+8
-0
scripts/core/handlers/create_excel_file.py
+3
-0
scripts/core/handlers/upload_and_insert_data.py
+4
-0
scripts/services/main.py
+1
-0
No files found.
scripts/core/handlers/create_excel_file.py
View file @
e035cbd7
...
...
@@ -16,15 +16,18 @@ def create_excel(app_api, collection):
}
}
]
records
=
list
(
collection
.
aggregate
(
pipeline
))
# Create an Excel Workbook and Worksheet
wb
=
openpyxl
.
Workbook
()
ws
=
wb
.
active
# Write column headers to Excel Worksheet
column_headers
=
list
(
records
[
0
]
.
keys
())
for
i
,
header
in
enumerate
(
column_headers
):
ws
.
cell
(
row
=
1
,
column
=
i
+
1
,
value
=
header
)
# Write data from MongoDB to Excel Worksheet
for
i
,
record
in
enumerate
(
records
):
for
j
,
key
in
enumerate
(
record
.
keys
()):
...
...
scripts/core/handlers/upload_and_insert_data.py
View file @
e035cbd7
...
...
@@ -8,14 +8,18 @@ def upload_and_insert_into_db(app_api, collection):
async
def
create_upload_file
(
file
:
UploadFile
):
data_frame
=
file
.
file
.
read
()
data_frame
=
data_frame
.
decode
()
uploaded_path
=
"temp/uploaded.json"
with
open
(
uploaded_path
,
"w"
)
as
json_file
:
# Write data to the file
json_file
.
write
(
data_frame
)
with
open
(
uploaded_path
,
"r"
)
as
uploaded_json
:
# Load the data from the file
data
=
json
.
load
(
uploaded_json
)
inserted
=
insert_data_to_mongodb
(
collection
,
data
)
if
inserted
:
print
(
"Data inserted to DB"
)
return
{
"filename"
:
file
.
filename
}
scripts/services/main.py
View file @
e035cbd7
# Importing Libraries
from
fastapi
import
FastAPI
from
scripts.constants.db_connection
import
db_connect
from
scripts.core.handlers.aggregate_operations
import
violated_companies
,
no_violated_companies
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment