Uploading multiple files and combining it to one file


(Vijay Kapoor) #1

I am trying to make an app which takes multiple files through user and then combine the data in the files in one particular file and store it into database . can I do this in Django if yes … then how can I do it


(PARTH JANI) #2

i have same question but i have little bit knowledge about how to do it as per you tell : PANDAS library is best answer,explorer pandas how to use it in your app and after deployed it on code ,that’s all.

image


(Vijay Kapoor) #3

the files are a txt or doc file which is combined in one particular file which is text file so the data from all the file is combined to one particular file
.


(Basil Jose) #4

You can achieve it simply by using the shutil

import shutil;
file1 = '/home/fingent/Projects/asplinks_new/media/reportfile/CA_FCAIBILLDET_B_044_0401_CAD.txt'                                                                                        

file2 = '/home/fingent/Projects/asplinks_new/media/reportfile/CA_FCAIBILLDET_B_044_0405_CAD.txt'                                                                                        

file3 = '/home/fingent/Projects/asplinks_new/media/reportfile/CA_FCAIBILLDET_B_joined.txt'                                                                                              

with open(file3, "wb") as wfd: 
   for f in [file1, file2]: 
      with open(f, "rb") as fd: 
         shutil.copyfileobj(fd, wfd, 1024*1024*10);

above code snippet is just an example, you need to change accordingly to full-fill your requirements.