title: Python how to read from and write to different files using multiprocessing
body: <p>I have several files and I would like to read those files, filter some keywords and write them into different files. I use Process() and it turns out that it takes more time to process the readwrite function. 
  Do I need to separate the read and write to two functions? How I can read multiple files at one time and write key words in different files to different csv?</p>
  
  <p>Thank you very much.</p>
  
  <pre><code>def readwritevalue():
      for file in gettxtpath():    ##gettxtpath will return a list of files
          file1=file+".csv"
          ##Identify some variable
  ##Read the file
          with open(file) as fp:
              for line in fp:
                  #Process the data
                  data1=xxx
                  data2=xxx
                  ....
           ##Write it to different files
          with open(file1,"w") as fp1
              print(data1,file=fp1 )
              w = csv.writer(fp1)
              writer.writerow(data2)
              ...
  if __name__ == '__main__':
      p = Process(target=readwritevalue)
      t1 = time.time()
      p.start()
      p.join()
  </code></pre>
  
  <p>Want to edit my questions. I have more functions to modify the csv generated by the readwritevalue() functions. 
  So, if Pool.map() is fine. Will it be ok to change all the remaining functions like this? However, it seems that it did not save much time for that.</p>
  
  <pre><code>def getFormated(file):  ##Merge each csv with a well-defined formatted csv and generate a final report with writing all the csv to one output csv
  
     csvMerge('Format.csv',file,file1)
     getResult()
  
  if __name__=="__main__":
      pool=Pool(2)
      pool.map(readwritevalue,[file for file in gettxtpath()])
      pool.map(GetFormated,[file for file in getcsvName()])
      pool.map(Otherfunction,file_list)
      t1=time.time()
      pool.close()
      pool.join()
  </code></pre>