0

system: raspberry pi 4 model B, 32bit, linux run python

Is a dumb question, I was planning to read data from MongoDB to excel' and also read excel toMongoDB'. Overall the .py scrip/code is fine and working. (the code is below)

I do know if in the code I import pandas as pd then raspberry pi cmd need to pip install it

  • my main quesion:

but we also acknowledge that raspberrypi's memory not as bigger as other laptop, is there other way instead of pip install all the stuff, we can still use them?
Becides, I only pip install pandas by raspberrypi took about 15 min, and laptop is like 30sec, and factory might have more than hundred of raspberrypis for recording such as temperature, product data etc on production line.

There should be an efficient way to implement (use pandas and other pymongo without manually pip install on raspberrypi)

  • the memory left:
joy@raspberrypi:/ $ free
               total        used        free      shared  buff/cache   available
Mem:         3834332      223876     2844436       72704      766020     3463004
Swap:         102396           0      102396
  • the fine code.py script MongoDB to excel:
import pandas as pd
from pymongo import MongoClient
import pymongo
from json2excel import Json2Excel
import json
from bson.objectid import ObjectId
from bson import json_util

client = pymongo.MongoClient("mongodb://localhost:27017/")
# Database Name
db = client["(practice_10_14)-0002"]
# Collection Name
col = db["(practice_10_24)read_MongoDB_to_Excel"]
#  Find All: It works like Select * query  of SQL. 
x = col.find()
list_01 = []
for data in x:
    list_01.append(data)
    print(data)


print("= = = = = ")
df = pd.DataFrame(data,index=[0])
 
# select two columns
for y in df:
    print(y)

print("= = = = = ")
print(type(list_01))


print(list_01)
df = pd.DataFrame(list_01)
writer = pd.ExcelWriter('test10.24.xlsx', engine='xlsxwriter')
df.to_excel(writer, sheet_name='welcome', index=False)
writer.save()
0

1 Answer 1

0

It is unclear what OS or what you have done or are trying to do.

Two things are clear using pip to install should be a last resort and you should not be using python2.

First you should try the repository - there is a python3-pandas and python3-pymongo which you can install with apt .

If you are trying to install on "hundred of raspberrypis" why not setup ONE image and duplicate?

1
  • thanks, this is the first time I heard concept Image, I will look for it
    – 44 chuang
    Commented Oct 26, 2022 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.