M
Matt Graves
I have a CSV file containing a bunch of URLs I have to download a file fromfor 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'
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'