Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I keep getting the Detail AttributeError: 'module' object has no attribute 'workbook' error.
below is my code
import xlwt
workbook = xlwt.workbook()
sheet = workbook.add_sheet('Eswar')
sheet.write (4,4,'Test passed')
workbook.save("D:\resultsLatest.xls")
what have i done wrong?
I am using python 2.7
In source code on github you can see right spelling Workbook. Your code should be:
import xlwt
workbook = xlwt.Workbook()
sheet = workbook.add_sheet('Eswar')
sheet.write(4,4,'Test passed')
workbook.save("D:\\resultsLatest.xls")
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 months ago.
Improve this question
Im parsing data for study purposes so I create scraping module, data frame module and now I need to finish "upload to Google Drive data frame as Google Sheet" but stuck on this error.
from fileinput import filename
import gspread
credentials = {...
}
gc = gspread.oauth_from_dict(credentials)
tag = bs_search
sh = gc.open(filename, 'kid')
worksheet = sh.add_worksheet(title = tag, rows=100, cols=20)
worksheet.update([df.columns.values.tolist()] + df.values.tolist())
worksheet.update_cell(1, 4, 'Send to')
worksheet.update_cell(1, 5, 'Not Send to')
worksheet.update_cell(1, 6, 'Instagram')
Output:
13 gc = gspread.oauth_from_dict(credentials)
15 tag = bs_search
---> 16 sh = gc.open(filename, 'kid')
17 worksheet = sh.add_worksheet(title = tag, rows=100, cols=20)
18 worksheet.update([df.columns.values.tolist()] + df.values.tolist())
AttributeError: 'tuple' object has no attribute 'open'
If you look at the docs for the gspread project, they have an example for this function:
gc, authorized_user = gspread.oauth_from_dict(credentials)
Notice there are two values before the equals.
More information: https://docs.gspread.org/en/latest/oauth2.html
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm trying to store my extracted chrome data into a csv format using df.to_CSV
here is my code :
content = driver.page_source
soup = BeautifulSoup(content)
for a in soup.findAll('a',href=True, attrs={'class':'_13oc-S'}):
name=a.find('div', attrs={'class':'_4rR01T'})
price=a.find('div', attrs={'class':'_30jeq3 _1_WHN1'})
rating=a.find('div', attrs={'class':'hGSR34 _2beYZw'})
products.append(name.text)
prices.append(price.text)
ratings.append(rating.text)
df = pd.DataFrame({'Product Name':products, 'Price':prices, 'Rating':ratings})
df.to_CSV(r'C:\Users\Krea\Documents\products.csv', index=False)
It's case-sensitive, should be df.to_csv(...)
Python is case sensitive. Change the last row to:
df.to_csv(r'C:\Users\Krea\Documents\products.csv', index=False)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm studying Flask very recently and trying to create API.
However, when It request json data, this error occurs.
if content['words'] is not None:
TypeError: 'NoneType' object is not subscriptable
could anyone can help this?
Thanks
my code is below:
#app.route("/process",methods=['GET', 'POST'])
def process():
content = request.json
words = {}
if content['words'] is not None:
for data in content['words'].values():
words[data['word']] = data['weight']
process_from_text(content['text'], content['maxCount'], content['minLength'], words)
result = {'result':True}
return jsonify(result
The problem is most likely that request is not a valid json request. If that is the case then content will be equal to None which means it is not subscriptable.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
Hello Guys I'm having problem on my code.
from selenium import webdriver
import time
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy_type',1)
profile.set_preference('network.proxy.http',"91.xx.xxx.xx")
profile.set_preference('network.proxy.http_port',xxxx)
# profile.update_preference() ---> this code letter giving the error.
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('http://whatismyipaddress.com')
time.sleep(3)
driver.close()
Here Is The Error I'm Getting:
AttributeError: 'FirefoxProfile' object has no attribute 'update'
I cant figure out the problem i just want to save the profile settings to use.
I Think You Need To Change This
profile.update_preference()
With This:
profile.update_preferences()
update_preferences()
update_preferences() updates the default_preferences with the frozen preferences of the desired FirefoxProfile which is defined as:
def update_preferences(self):
for key, value in FirefoxProfile.DEFAULT_PREFERENCES['frozen'].items():
self.default_preferences[key] = value
self._write_user_prefs(self.default_preferences)
However, you were close. You need to replace update_preference() with update_preferences() i.e. effectively in your code you need to replace:
profile.update_preference()
with
profile.update_preferences()
References
You can find a relevant discussions in:
How to connect to Tor browser using Python
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am trying to read a huge file lazily in with the pandas get_csv function. I want to access the first 5000 elements of a specified column. But I am getting the error I mentioned in my title.
#fetching data
train = pd.read_csv(os.path.join(dir,"Train.csv"),iterator = True)
test = pd.read_csv(os.path.join(dir,"Test.csv"),iterator = True)
Getting the parts of the data I need:
labels = np.array(train.get_chunk(5000))[:,3]
train = np.array(train.get_chunck(5000))[:,2]
test = np.array(test.get_chunk(5000))[:,2]
Error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-43-b164e8752510> in <module>()
1 labels = np.array(train.get_chunk(5000))[:,3]
----> 2 train = np.array(train.get_chunck(5000))[:,2]
3 test = np.array(test.get_chunk(5000))[:,2]
AttributeError: 'TextFileReader' object has no attribute 'get_chunck'
Apparently I am not allowed to do it like this? If not, how could I rewrite this to achieve what I am trying to achieve with this code?
get_chunck is a spelling error!
Try get_chunk instead of get_chunck.
get_chunck is the culprit ! get_chunk