Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1041793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:24:25+00:00 2026-05-16T15:24:25+00:00

The idata I pulled from this URL needs to be turned into a sequence,

  • 0

The “idata” I pulled from this URL needs to be turned into a sequence, how do i turn it into a sequence

import urllib, csv

URL = "http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=sl1vt1&e=.csv"
symbols = ('GGP', 'JPM', 'AIG', 'AMZN','GGP', 'JPM', 'AIG', 'AMZN')
#symbols = ('GGP',)

def fetch_quote(symbols):
    url = URL % '+'.join(symbols)
    fp = urllib.urlopen(url)
    try:
        data = fp.read()
    finally:
        fp.close()
    return data # <======== Return

idata = fetch_quote(symbols)
print idata

Python URL download

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:24:26+00:00Added an answer on May 16, 2026 at 3:24 pm

    What do you mean by “a sequence”? You could turn it into a dictionary as follows. Just place this code after you produce idata.

    stocks = {}
    for line in idata.split("\r\n"):
        if line == '':
            continue
    
        stock, price, volume, stime = line.split(',')
        stock = stock[1:-1]
        price = float(price)
        volume = int(volume)
        stime = stime[1:-1]
    
        stocks[stock] = (price, volume, stime)
    

    If you want to be a bit more robust, you can use the csv module (add import csv to the top of your code) then use

    reader = csv.reader(idata.split("\r\n"))
    
    stocks = {}
    for line in reader:
        if line == '':
            continue
    
        stock, price, volume, stime = line
        price = float(price)
        volume = int(volume)
    
        stocks[stock] = (price, volume, stime)
    

    For inserting into a database, the following may work

    reader = csv.reader(idata.split("\r\n"))
    
    stocks = []
    for line in reader:
        if line == '':
            continue
    
        stock, price, volume, stime = line
        price = float(price)
        volume = int(volume)
    
        stocks.append((stock, price, volume, stime))
    
    csr.executemany('INSERT INTO test.prices VALUES (?,?,?,?)', stocks)
    

    This of course assumes your columns are in the same order as the elements of the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if (current.leftChild.iData != '+' && current.rightChild.iData != '+') For this line of code i
i have situation like this: class IData { virtual void get() = 0; virtual
Im coding a problem(reference --http://www.codechef.com/FEB11/problems/THREECLR/) The below is my code import java.io.*; import java.util.*;
I am using NSXMLParser like this : - (BOOL)parseXMLData:(NSData *)inData { provisioningParser = [[NSXMLParser
boolean isdata=false; // converting this to true String qname=data; String abc=is+qname; isdata = true
Consider the following code sample: interface IData { int Count(); } interface IOperations {
I found this code in NVIDIA's CUDA SDK samples. void computeGold( float* reference, float*
here is full code from algorithm and data structure in java written in c++
This post contains a lot of code, but I would really appreciate it if
How to remove item from jquery array object. I used splice method as follows.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.