0

I am writing a script which is supposed to read all files from a specific location and do some manipulation and then write back to another folder and not the parent directory. This is what I am trying :

   for i in np.arange(0, len(json_files),1):
    os.chdir(r"D:\Ashutosh 3D\Experiments\AnakinLogs\buildmanagerlogs")
    instance = anakinLog(json_files[i])
    os.chdir(r"D:\Ashutosh 3D\Experiments\AnakinLogs\buildmanagerlogs\csv_output")
    instance.parseAllJson()

I am explicitly setting this to return to the home directory but is there a better python way of handling this situation ? Also, how can I add parallelism to this code to run even faster ?

Andrii Maletskyi
  • 2,152
  • 1
  • 15
  • 24
  • why are you changing the directory? – Jeril Mar 14 '19 at 11:01
  • @Jeril Because I need the file funclist to be saved in home directory but it should be able to read files in other directories. – ashutosh karna Mar 14 '19 at 22:20
  • How are you saving it in the home directory? In which line is the code used for saving – Jeril Mar 15 '19 at 04:36
  • Currently, I am not. The script saves the file in new directory which is what I wanted to change. Do you have have any suggestion how ? – ashutosh karna Mar 15 '19 at 12:30
  • which is the line that saves the code – Jeril Mar 15 '19 at 12:36
  • The last question should be posted as a separate question (or I'm sure a searching SO by "parallel loop python" would save your time) – Ignatius Mar 29 '19 at 00:41
  • Duplicate https://stackoverflow.com/questions/6194499/pushd-through-os-system On unix, there is a command name `pushd` and `popd` you can emulate with a stack and os.chdir – user1462442 Mar 29 '19 at 01:27

0 Answers0