List not allowing .splitlines() - Python


What do I need to do to prevent the error: AttributeError: 'list' object has no attribute 'split lines' from occurring here? How to I convert the list that I have into a form that can have splitlines attributed to?

import requests import re from bs4 import BeautifulSoup import csv #Read csv with open ("gyms4.csv") as file: reader = csv.reader(file) csvfilelist = [row[0] for row in reader] print csvfilelist #Get data from each url def get_page_data(): for page_data in csvfilelist.splitlines(): r = requests.get(page_data.strip()) soup = BeautifulSoup(r.text, 'html.parser') yield soup


The <a href="https://docs.python.org/2/library/stdtypes.html#str.splitlines" rel="nofollow">str.splitlines() method</a> only works on a string object. You don't have a string object, you have a list of strings:

csvfilelist = [row[0] for row in reader]

There is no need to split this, you already have the first column of each line in the file. Just remove the .splitlines() call:

for page_data in csvfilelist:


  • Python- Scrapping images using requests
  • How to set iOS UITextField placeholder color? (RubyMotion + iOS)
  • NSTextAttachment image not displayed on iOS 8 devices (with iOS7.1 sdk)
  • Simple regex for simple xml string
  • How to change color of single letters or one word in line
  • Extremely Odd Crash When saving a transformable NSAttributedString into Core Data
  • issues with writing Chinese to csv file in Python
  • AttributeError: 'NoneType' object has no attribute 'findAll'
  • how to POST contents of JSON file to RESTFUL API with Python using requests module
  • trying to split the file download buffer to into separate threads
  • Scraping graph data from a website using Python
  • Scraping a page for URLs using Beautifulsoup
  • Python scrape value between static HTML tags containing static text
  • Beautiful Soup parsing inline and into dictionary
  • TypeError : 'NoneType' object not callable when using split in Python with BeautifulSoup
  • Error while trying to upload file using kairos
  • BeautifulSoup and   [duplicate]
  • Scrap the absolute URL instead of a relative path in python
  • Ajax Loaded meta Tags
  • Exchange data b/w iOS devices using Bluetooth 4.0
  • Master page gives error
  • Uncaught Error: Could not find module `ember-load-initializers`
  • Apache 2.4 and php-fpm does not trigger apache http basic auth for php pages
  • How to set/get protobuf's extension field in Go?
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Sending data from AppleScript to FileMaker records
  • Running a C# exe file
  • Can I make an Android app that runs a web view in Chrome 39?
  • Symfony2: How to get request parameter
  • Google cloud sdk not working when python points python3
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Python: how to group similar lists together in a list of lists?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • Busy indicator not showing up in wpf window [duplicate]