laPepita / MailchimpGoalsToCsv

access the mailchimp API you can pull the goals out as a CSV file.
GNU General Public License v3.0
0 stars 0 forks source link

Error: Files could not be replaced... There are already files existing with the same name... #1

Open latitude4all opened 5 years ago

latitude4all commented 5 years ago

I have tried to use the script but at the end I've got an error message:

Traceback (most recent call last):
  File "Json2csv-master/json2csv.py", line 156, in <module>
    loader.write_csv(filename=outfile, make_strings=args.strings)
  File "Json2csv-master/json2csv.py", line 98, in write_csv
    raise AttributeError('No rows were loaded')
AttributeError: No rows were loaded
 Files could not be replaced... There are already files existing with the same name... Please move or delete them
Traceback (most recent call last):
  File "Json2csv-master/json2csv.py", line 156, in <module>
    loader.write_csv(filename=outfile, make_strings=args.strings)
  File "Json2csv-master/json2csv.py", line 98, in write_csv
    raise AttributeError('No rows were loaded')
AttributeError: No rows were loaded
 Files could not be replaced... There are already files existing with the same name... Please move or delete them

Full function is done running

I am using Python 3.7.1 32bit on Windows. I have tried to use full path and also I have tried to run a script from the directory using a full path but so far the same error.

latitude4all commented 5 years ago

I already checked under Ubuntu on Windows the same result...

python: can't open file 'Json2csv-master/json2csv.py': [Errno 2] No such file or directory
 Files could not be replaced... There are already files existing with the same name... Please move or delete them
python: can't open file 'Json2csv-master/json2csv.py': [Errno 2] No such file or directory
 Files could not be replaced... There are already files existing with the same name... Please move or delete them

Full function is done running
  _________
 /         \
 |  /\ /\  |
 |    -    |
 |  \___/  |
 \_________/

Do you know how to fix that? I have tried to use full path and also I have tried to run a script from the directory of init.py using a full path but so far the same error.

laPepita commented 5 years ago

Hi,

It's been a while since I put this script together. Do you have the https://github.com/evidens/json2csv working? From memory, if that is not set up correctly then it causes this problem.

latitude4all commented 5 years ago

I just installed json2csv as it is described

git clone https://github.com/evidens/json2csv.git
cd json2csv
pip install -r requirements.txt

Should it be cloned to the same folder as ./Mailchimp-Goals2csv/json2csv-master

I have cloned in my home folder but so far the same result.

So right now I have json2csv here: /home/user/json2csv/

and your script is here: /home/user/pt/MailchimpGoalsToCsv-master/Mailchimp-Goals2csv/__init__.py

and also I have a default folder from your package: /home/user/pt/MailchimpGoalsToCsv-master/Mailchimp-Goals2csv/json2csv-master

laPepita commented 5 years ago

Hmmm.... I'm busy at the moment. I will try and have a look at it tomorrow. As I said, it's been 2 years since I opened this script. The below part of the script is what is throwing the error. Are any directories or files being created?


                # Trigger the Json 2 CSV maker
                ##############################

                #Change Directory to output folder

                # Build the CSV file for the member specific data
                subprocess.call(['python', 'Json2csv-master/json2csv.py', names[0], "master.outline.json"])

                try:
                    shutil.move(names[0],"../GoalJSONFolder" + current)
                    a = names[0].rstrip(names[0][-4:])
                    shutil.move(a + "csv","../GoalCSVFolder" + current)
                except:
                    print (" Files could not be replaced... There are already files existing with the same name... Please move or delete them")

                # Build the CSV file for the Goal overview data
                subprocess.call(['python', 'Json2csv-master/json2csv.py', names[1], "masterOverview.outline.json"])

                try:
                    shutil.move(names[1], "../GoalJSONFolder" + current)
                    a = names[1].rstrip(names[0][-4:])
                    shutil.move(a + "csv", "../GoalCSVFolder" +  current)
                except:
                    print (" Files could not be replaced... There are already files existing with the same name... Please move or delete them")
            except:
                e = sys.exc_info()[0]
                print ("Error: %s" % e)
                print ("LIST ID is not valid for this Argument.....")```
latitude4all commented 5 years ago

Yes. The script creating directory after run:

The original script is placed here: /home/user/pt/MailchimpGoalsToCsv-master/Mailchimp-Goals2csv/__init__.py And after running the script creating directory here:

~/pt/MailchimpGoalsToCsv-master/GoalJSONFolder Sun Dec 23 105402 2018

So in the directory, I can see 2 files:

listname.json
listnameOverview.json

Each of the files has the same content which is:


{
    "Full": []
}
~              

And nothing more, but actually the script is getting data, I can see messages like that;

--- Members processed = 412

The only problem is that the script cannot write the output to the file correctly. After processing all of the members from the list I am getting an error:

---  Members processed = 490
---  Members processed = 491
---  Members processed = 492
python: can't open file 'Json2csv-master/json2csv.py': [Errno 2] No such file or directory
 Files could not be replaced... There are already files existing with the same name... Please move or delete them
python: can't open file 'Json2csv-master/json2csv.py': [Errno 2] No such file or directory
 Files could not be replaced... There are already files existing with the same name... Please move or delete them

Full function is done running
  _________
 /         \
 |  /\ /\  |
 |    -    |
 |  \___/  |
 \_________/
latitude4all commented 5 years ago

Merry Christmas! Is it any updates?.. Thank you!

laPepita commented 5 years ago

Hi,

I've been away with no laptop since before Christmas, hence the difficulty in replying. I should have a laptop again on Jan 2nd but for now can you modify the RootCall.py script and uncomment out the print member statements?:

        #make the API call for the currently selected user
        goalResponse = requests.get(baseURL + member["id"] + "/goals", auth=('APIuser', APIKey))
        print("---  Members processed = " + str(i + 1))
        # print member["email_client"]
        # print goalResponse.text

If it's confirmed that the script is actually writing the member data then can you please have the folder open when running the script? You should see the folders move or try and overwrite each other.

If they aren't moving then and the Json2csv-master/json2csv.py file is actually there then the script is encountering an error in a try, except loop and failing in the wrong directory. If that's the case I will have to take a proper look at it when I have a lappie.

laPepita commented 5 years ago

I actually uncommented some print statements (classic remote debugging haha) pull and run it again and check the above.