0

I have a task to read a punch of data from excel file and read images from folder then insert them into the database.

the excel sheet is like :

-------------
Name    |Id -
Photo x |1  -
Photo y |2  -
-------------

and i have a database table like:

==============
Name |Binary =
==============

The photos in the folder is names by id like (1.jpg,...ect) to match the excel sheet

So my idea is to read all images paths from the folder like(1500 images) and add them to list (list of image paths) then read the data from the excel and add them all together

I could read the data from the excel file easy and read all columns easy loop and insert them in the database, but the problem is how could i read images and insert them with the excel data all together ?

Mostafa Mohamed
  • 816
  • 15
  • 39
  • Do you want to insert the name of the image file in the db, or actually store the image in the db? The latter doesn't sound like a good idea. Do you know how to read the excel sheet? and insert its data into your db? – joel goldstick Mar 19 '16 at 20:07
  • when you insert into db, just add filename that you can gleen from the id. Do you want to insert the actual image into the db or just its name? – joel goldstick Mar 19 '16 at 20:10
  • This might be instructive: http://stackoverflow.com/questions/54500/storing-images-in-postgresql – joel goldstick Mar 19 '16 at 20:14
  • yea i want to insert the image in binary field not the name of it – Mostafa Mohamed Mar 20 '16 at 14:56

1 Answers1

1

You have a function that reads from the excel file, you also have another that reads the images, since the images are named after the Id column from the excel sheet you can find which image belongs to each role of the excel sheet. Example sudo code: for data in excel sheet with id x, get image named or has id x.

azdonald
  • 336
  • 1
  • 3
  • 16
  • You did not understand my question dear ,,, i don't have the function to read the images! i need it .. i need a function to read all images to insert it into the database with my data of excel sheet – Mostafa Mohamed Mar 19 '16 at 19:18
  • If you want to store the actual image into the database(bad idea), you can use a library like opencv or the python image library. – azdonald Mar 20 '16 at 11:11