• Register
1 vote
536 views

Problem:

When I run or compile this program

import urllib2
import time
import datetime

HolaAndre = 'HUA','WALT','NOKA','CMG','EVAL','DARZ','SYM'

def BackData(stock):
    try:
        print 'Still pulling',stock
        print str(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
        urlToVisit = 'http://chartapi.finance.yahoo.com/instrument/1.0/'+stock+'/chartdata;type=quote;range=5d/csv'
        saveFileLine = stock+'.txt'

        try:
            readExistingData = open(saveFileLine,'r').read()
            splitExisting = readExistingData.split('\n')
            mostRecentLine = splitExisting[-2]
            lastUnix = mostRecentLine.split(',')[0]
        except:
            lastUnix = 0

        saveFile = open(saveFileLine,'a')
        sourceCode = urllib2.urlopen(urlToVisit).read()
        splitSource = sourceCode.split

        for eachLine in splitSource:
            splitLine = eachLine.split(',')
            if len(splitLine) ==6:
                if splitLine[0] > lastUnix:
                    if 'values' not in eachLine:
                        lineToWrite = eachLine+'\n'
                        saveFile.write(lineToWrite)

        saveFile.close()

        print 'Pulled',stock
        print 'sleeping...'
        print str(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
        time.sleep(300)

    except Exception,e:
        print 'main loop',str(e)

for eachStock in HolaAndre:
    BackData(eachStock)

It shows me the following error

main loop 'builtin_function_or_method' object is not iterable

What is the problem please help me.

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

1 vote
 
Best answer

Answer:

The error you getting because of the line

splitSource = sourceCode.split

Change this line to

splitSource = sourceCode.split()

By changing this thing I think your code should work properly.

Happy coding.

11 6 4
34,950 points

Related questions

0 votes
1 answer 23 views
23 views
Problem: How to I Solve this: python typeerror: 'nonetype' object is not iterable HELP! I need help understanding this: python typeerror: 'nonetype' object is not iterable Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 3 Mashhoodch 13k points
0 votes
1 answer 26 views
26 views
Problem: I am looking to make a loop so that for each element in the list, it will get broken down into each of it's characters. For example, say the number 137 was in the list then it would be turned into [1,3,7]. Then I want to add these numbers together (I ... it). However, I keep getting the error message TypeError: 'int' object is not iterable when I try and run this. What am I doing wrong?
asked Feb 23 Mashhoodch 13k points
0 votes
1 answer 91 views
91 views
Problem: What the traceback error is pointing out is the misuse of for statement: for i in Updt():. for in python 3 i "Python's for statement iterates? How function' object is not iterable. from getWords import getWords unique = [] def findUniqueWords(words): for word in words
asked Feb 15 Mashhoodch 13k points
0 votes
1 answer 89 views
89 views
Problem: Hi there! I am a beginner and do not have much experience in programming. I am trying to run the following program: entries = int(input("Enter the number of items you want to add in the list: ")) lis = [] for i in range(1, entries+1): lis.append ... not know what I am doing wrong. This program was working correctly till yesterday, but I do not know what is wrong with it now. Please help.
asked Jan 16 Code Learner 9.9k points
0 votes
1 answer 35 views
35 views
Problem: I have this error and I can’t solve it, any help: TypeError: cannot unpack non-iterable NoneType object
asked Mar 14 Wafa Abu Yousef 6.1k points
1 vote
2 answers 2K views
2K views
Problem: I wrote a code in python but it throws me a error message: Please enter your number: 13 Traceback (most recent call last): File "tst.py", line 20, in <module> (lub, sup) = fib_intervall(a) TypeError: cannot unpack non-iterable NoneType object The code I ... me but after that the code is not running and throwing me this error message. Is there any problem in my code and how to solve this?
asked Apr 24, 2020 samhaz 5k points
0 votes
1 answer 13 views
13 views
Problem: How I can fix this : builtin_function_or_method' object is not subscriptable python
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
2 answers 2.1K views
2.1K views
Problem : Here's my code def defausse_rack_prov(word,rack_prov): word=word.get() for i in word: if i.upper() in rack_prov: rack_prov[rack_prov.index[i]]='' #This is the problematic line return rack_prov I keep getting TypeError: 'builtin_function_or_method' object is not subscriptable What should I do ?
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
1 answer 7 views
7 views
problem: I need someone to understand the problem and solve the issue of typeerror: 'int' object is not iterable ?
asked Apr 5 ashik 14.6k points
0 votes
1 answer 463 views
463 views
Problem: Django I have the following models: class Group(models.Model): name = models.CharField(max_length=100) parent_group = models.ManyToManyField("self", blank=True) def __unicode__(self): return self.name class Block(models.Model): name = models.CharField(max_length= ... return blocks But b1.group.block_set returns me a RelatedManager object that cannot be repeated. What to do? What's wrong?
asked Dec 13, 2020 sasha 16.2k points