I have a list of urls in a csv file and I need to run them in for eachUrl in final_url: but I keep getting a traceback error because I find out that when I print the urls from the below code, it is also printing out ['https://www.anyurl.com'] and not just the url. I have tried to run a loop to replace the [' '] but I get the traceback error AttributeError: 'list' object has no attribute 'replace'. How do I open the csv and just pull out the URL's and put them into a list without putting them into a list inside another list?
import csv
with open('urls_for_BrightScope_Form5500s.csv', 'r') as r:
reader = csv.reader(r)
for row in reader:
final_urls.append(row)
print(len(final_urls))
Output from final_url list: ['https://www.brightscope.com/401k-rating/372254/Merritt-Brothers-Lumber-Company/377291/Merritt-Brothers-Lumber-Co-401K-Profit-Sharing-Plan/'], ['https://www.brightscope.com/401k-rating/255132/Merritt-Club-Management-Inc/259235/Merritt-Club-Management-Inc-401K-Profit-Sharing-Plan-And-Trust/'], ['https://www.brightscope.com/401k-rating/404751/Merritt-Equipment-Co/410055/Merritt-Equipment-Co-401K-Profit-Sharing-Plan/'], ['https://www.brightscope.com/401k-rating/256405/Merritt-Hospitality-Llc/260527/Merritt-Hospitality-401K-Plan/']
['https://www.anyurl.com'], i.e. it has only one cell, I would say that this is not really a CSV file at all. Why are you reading it as if it was CSV?final_urls? And it would be also good if you can provide us an excerpt from your csv file.