Re: Downloading multiple files based on info extracted from CSV

2013-12-16 Thread Matt Graves
On Thursday, December 12, 2013 5:20:59 PM UTC-5, Chris Angelico wrote:

 import urllib
 
 import csv
 
 
 
 # You actually could get away with not using a with
 
 # block here, but may as well keep it for best practice
 
 with open('clients.csv') as f:
 
 for client in csv.reader(f):
 
 urllib.urlretrieve(client[7], client[0] + .csv)
 
 
 
 Yep, that's it! That's all you need. 


Worked perfect. Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Downloading file

2013-12-12 Thread Matt Graves
I have direct links to a number of csv files to download. Copying and pasting 
it to my browser would take too long, how would i go to this site for example 
and get the file? Right when you go to the site the download should start

www.example.com/files/document.csv
-- 
https://mail.python.org/mailman/listinfo/python-list


Downloading multiple files based on info extracted from CSV

2013-12-12 Thread Matt Graves
I have a CSV file containing a bunch of URLs I have to download a file from for 
clients (Column 7) and the clients names (Column 0) I tried making a script to 
go down the .csv file and just download each file from column 7, and save the 
file as [clientname].csv

I am relatively new to python, so this may be way off but…






import urllib 
import csv
urls = []
clientname = []

###This will set column 7 to be a list of urls
with open('clients.csv', 'r') as f:
reader = csv.reader(f)
for column in reader:
urls.append(column[7])

###And this will set column 0 as a list of client names
with open('clients.csv', 'r') as g:
reader = csv.reader(g)
for column in reader:
clientname.append(column[0])

###This SHOULD plug in the URL for F, and the client name for G.
def downloadFile(urls, clientname):
urllib.urlretrieve(f, %g.csv) % clientname


downloadFile(f,g)



When I run it, I get : AttributeError: 'file' object has no attribute 'strip'
-- 
https://mail.python.org/mailman/listinfo/python-list


Jabberbot

2013-11-13 Thread Matt Graves
I'm using the jabberbot library and there is not a whole lot of documentation 
on it. Does anyone have experience with this library?

This is basically the only example given:


-
from jabberbot import JabberBot, botcmd
import datetime

class SystemInfoJabberBot(JabberBot):
@botcmd
def serverinfo( self, mess, args):
Displays information about the server
version = open('/proc/version').read().strip()
loadavg = open('/proc/loadavg').read().strip()

return '%s\n\n%s' % ( version, loadavg, )

@botcmd
def time( self, mess, args):
Displays current server time
return str(datetime.datetime.now())

@botcmd
def rot13( self, mess, args):
Returns passed arguments rot13'ed
return args.encode('rot13')

@botcmd
def whoami(self, mess, args):
Tells you your username
return mess.getFrom().getStripped()


username = 'xxx...@..com'
password = 'x'
bot = SystemInfoJabberBot(username,password)
bot.serve_forever()

-
I cannot figure out how I would have it simulate a conversation. For example, 
if I added 

@botcmd
def Hello(self, mess, args):
return Hi, how are you?

how would I get it to carry on from here? To look for different answers to the 
response that was returned. Any bit of information would be appreciated. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Jabberbot

2013-11-13 Thread Matt Graves
On Wednesday, November 13, 2013 11:32:24 AM UTC-5, Mark Lawrence wrote:
 On 13/11/2013 16:12, Matt Graves wrote:
 
  I'm using the jabberbot library and there is not a whole lot of 
  documentation on it. Does anyone have experience with this library?
 
 
 
 
 
 [snip code from http://thp.io/2007/python-jabberbot/]
 
 
 
  I cannot figure out how I would have it simulate a conversation. For 
  example, if I added
 
 
 
   @botcmd
 
   def Hello(self, mess, args):
 
   return Hi, how are you?
 
  
 
  how would I get it to carry on from here? To look for different answers to 
  the response that was returned. Any bit of information would be appreciated.
 
 
 
 
 
  From the link above More examples
 
 
 
 Starting with version 0.7, more examples can be found in the examples/ 
 
 subdirectory of the source distribution.
 
 
 
 Have you looked at these?
 
 
 
 -- 
 
 Python is the second best programming language in the world.
 
 But the best has yet to be invented.  Christian Tismer
 
 
 
 Mark Lawrence

I have, but unfortunately they are about just as clear as the example I posted. 
The examples they posted are relevant for certain things, but not what I'm 
looking to do. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Python HTTP POST

2013-07-17 Thread Matt Graves
I am going to be creating a python script that will make filling in information 
at my job easier.

I have all of the information I need... I guess I just need to see it in 
practice to fully grasp it.

How would I submit a python HTTP POST request to... for example, go to 
google.com, enter Pie into the search box and submit (Search)
-- 
http://mail.python.org/mailman/listinfo/python-list


String object has no attribute append

2013-05-28 Thread Matt Graves
I receive this error while toying around with Functions...

def pulldata(speclist,speccolumn):
with open('profiles.csv', 'r') as f:
  reader = csv.reader(f)
  for column in reader:
 (speclist).append(column[('speccolumn')])

pulldata(speclist = 'numbers', speccolumn = 0)


Traceback (most recent call last):
  File C:\Desktop\Python\CFI\Devices V2\users.py, line 17, in module
pulldata(speclist = 'numbers', speccolumn = 0)
  File C:\Desktop\Python\CFI\Devices V2\users.py, line 16, in pulldata
(speclist).append(column[('speccolumn')])
AttributeError: 'str' object has no attribute 'append'

I'm getting the error because it should say numbers.append, but it is reading 
it as (speclist).append.

This is my first time playing with functions, so be gentle. 
-- 
http://mail.python.org/mailman/listinfo/python-list