📜 ⬆️ ⬇️

We export comments and ratings from Google Play for analysis.

Not everyone knows, but on Google Play there is a completely legal opportunity to upload all comments and ratings to your application into a separate CSV file, after which you can do some kind of analysis that is not accessible from the Google system. But this is done using the external utility gsutil, written in Python. So in this post there will be a small instruction on how to do this.

  1. Install python 2.6 or 2.7 if it is not already in the system. Installation instructions on the official website , there is nothing difficult for any OS.

  2. Download and unpack to any folder gsutil ( direct link to zip , direct link to tar.gz )

  3. Open the console in the folder with gsutil and continue to work in it. (For windows - shift + right click in this folder and select “Open command window”, users more popular and themselves know how to do it, since they managed to install them)
    ')
  4. Execute the command
    gsutil.py update 

    for obvious purposes. Usually in the archive is already the latest version, but there is anything.



  5. Execute the command
     gsutil.py config 



    We get about this message. What to do, again, obviously - copy the link into the browser.

  6. Following the link we will get to the page where we allow the application to work with our account.


  7. And copy the code to the console




  8. In response, we will receive another message, with a proposal to choose a project by default in the Google Developer Console , but this is not necessary, especially since the project we need may simply not be there. But you need to enter something into the script, it will not accept the empty string. So just enter “1” for example and finish the job.



  9. On the App Ratings and Reviews page of your application, you need to find the report segment identifier starting with the string pubsite_prod_rev_ , for example, pubsite_prod_rev_1234567890123456789 .





  10. Now no one bothers us to download all the reports. To do this, just run the command
     gsutil.py -m cp gs://pubsite_prod_rev_1234567890123456789/reviews/*.* ___ 

    In our case:
     gsutil.py -m cp gs://pubsite_prod_rev_1234567890123456789/reviews/*.* C:\Python27\texts 

    -m - copy flag in several parallel threads
    cp is the file copy command.
    Details on the utility commands can be found here .

  11. As a result, in the folder we will get a bunch of files with names according to the reviews_ scheme [application_pack_name] _YYYYMM (Y - year, M - month). And for all applications assigned to your account immediately.



    Of course, if you need reports for only one application, you can download data with a query like
     gsutil.py -m cp gs://pubsite_prod_rev_1234567890123456789/reviews/* com.new_program*.* C:\Python27\texts 

    But, I think, the principle of filtering is clear.

  12. In general, everything is already fine, but working with a pack of individual files is inconvenient, so with a simple Python script we glue them together into one file. Of course, it would be possible to combine the files into one simple copy command, but then we will have a duplicate header, which is unpleasant.

     import os import codecs files = os.listdir(".") csvs = filter(lambda x: x.endswith(".csv") and x!="all_csv.csv", files) file_write = codecs.open('all_csv.csv', 'w','utf-16') header_writed = False for file_name in csvs: file_read = codecs.open(file_name,'r','utf-16') lines_count=0 for line in file_read: lines_count=lines_count+1 if (lines_count == 1): if (header_writed == False): header_writed = True file_write.write(line) else: file_write.write(line) file_read.close() file_write.close() 


Well, that seems to be all. The resulting file in Excel looks like this:






And what kind of analytics to create with the resulting file - see for yourself. :)

References


support.google.com/googleplay/android-developer/answer/138230#export_ratings_and_reviews
developers.google.com/storage/docs/gsutil

Source: https://habr.com/ru/post/236939/


All Articles