ptwobrussell / Mining-the-Social-Web

The official online compendium for Mining the Social Web (O'Reilly, 2011)
http://bit.ly/135dHfs
Other
1.21k stars 491 forks source link

Protovis: Introduction Retweet Visualization #53

Closed terminator1 closed 11 years ago

terminator1 commented 11 years ago

Hi Matthew,

I'm trying to work through the Protovis Retweet Visualization code you referenced in the book:

https://github.com/ptwobrussell/Mining-the-Social-Web/blob/master/python_code/introduction__retweet_visualization.py

After working through some directory issues with the code, I get stuck at: html = open(HTML_TEMPLATE).read() % (json_data,) if not os.path.isdir(OUT_DIR): os.mkdir(OUT_DIR) f = open(os.path.join(os.getcwd(), OUT_DIR, out_file + ".html"), 'w') f.write(html) f.close()

With the error being: Traceback (most recent call last): File "C:\Python27\trends", line 343, in protovis_output = write_protovis_output(g, OUT) File "C:\Python27\trends", line 276, in write_protovis_output html = open(HTML_TEMPLATE).read() % (json_data,) TypeError: not all arguments converted during string formatting

Something to do with string formatting being wrong. I noticed that you resolved the problem for someone running a recipe code with Protovis. You mentioned that is was a problem with Twitter updating the API to 1.1.

I'm a little confused, because in the source code you explicitly mention that you updated the code to API 1.1, so I don't understand why it would crash for me :(

As mentioned earlier, I had to hard code some directories and files as to not get a "This directory or filename does not exist" error. I hope it is not contributing to the string formatting error I'm getting now.

Thanks for your time!

ptwobrussell commented 11 years ago

You have mentioned a couple of things that make me wonder if you are working from a full checkout of the source code or if you have just downloaded this one file and are working with it. Could you just confirm that you have downloaded the entire repository and are working from it before we get too far into this?

terminator1 commented 11 years ago

Hi Matthew,

I've believe I'm working with the full repository.

I've been going through your examples and keeping all necessary entities from the previous example codes to proceed. Is that the same thing?

Is there a single place to download everything in one script?

I see that there is a web_code folder. Do I need all the included files when I run my script? (as mentioned previously, I've changed the directory that the code is looking for files as to avoid a "file not found" error, but I don't have all those extra files that you have in the web_code folder).

Thanks!

ptwobrussell commented 11 years ago

What I was trying to ask was whether you used git to do a 'git clone' on the full repository or if you just downloaded a couple of scripts a la carte. On the main page of the repository, there's also a "ZIP" button that you can click on at the top of the screen to download all of the code in one archived bundle. I'd recommend you use that link to download all of the code and work from there. Here's the URL to that link for convenience: https://github.com/ptwobrussell/Mining-the-Social-Web/archive/master.zip

If you are already doing this, I apologize for the confusion, but it sounds as though you don't have all of the code checked out on your machine, and that's causing you some problems. Does this make sense or am I misunderstanding?

terminator1 commented 11 years ago

Hi Matthew,

GitHub and the whole repository world is new to me, so I might not have been doing everything right.

Let me follow your instructions to get everything and play with it for a while.

Will get back to you and see if I still have the problem.

Thanks much!!

terminator1 commented 11 years ago

Matthew is the boss!!

I ran the script, only updating the Q variable to hard-coded text, and next thing I know a nice protovis graph came up in my browser.

Thanks for your patients!

My next project is Redis, which has been giving me hell because I'm running it on Windows, but I'll open a separate ticket on that.

ptwobrussell commented 11 years ago

Excellent!