NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


import csv
from pymongo import MongoClient
from multiprocessing import Pool

# Define a function to export data in batches
def export_batch(batch_num):
batch_size = 10000 # Adjust batch size as needed
skip = batch_num * batch_size
cursor = collection.find({}).skip(skip).limit(batch_size)

csv_file_path = 'MLMonitorData.csv' # Use a single CSV file

with open(csv_file_path, 'a', newline='') as csvfile: # Append mode
fieldnames = [
"_id",
"factory_id",
"dcu_id",
"conveyor_id",
"LinkNumber",
"ChainSpeed",
"MainDrive",
"LubeCycleN1",
"LubeCycleN2",
"LubeCycleN3",
"LubeCycleN4",
"LubeRequest",
"LubeVersion",
"LubeLevel",
"LubeVoltage",
"PumpVersion",
"PumpNum",
"PumpIp",
"DCUDateTime",
"created_at",
"updated_at"
]
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

for document in cursor:
# Write the document
writer.writerow(document)

# Determine the number of batches based on your dataset size
batch_size = 10000 # Adjust batch size as needed
total_records = total_count # Replace with the actual count

num_batches = (total_records // batch_size) + 1

if __name__ == '__main__':
with Pool(processes=4) as pool: # Adjust the number of processes as needed
pool.map(export_batch, range(num_batches))

# Close MongoDB connection
client.close()

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.