arrays - List stock data by weeks and days using Python -


I want to list various stock data published in a week. Stock data should be in all different array Different array elements should represent different days and arrays should be themselves for different weeks. So for example week_1 [55.5, 23.1234.8, 23.6] . I have tried so far which code can be seen below, but unfortunately it just does not work. I always get an error: 'str' does not support item item assignment . Any simple idea how can I fix this?

Python Code:

  import datetime # open csv file lines = open ("google CSV") line = lines. Reid () line = lines. Split ("\ n") i = 0 while i  

CSV File:

  2011-02-07,610.16,618.39, 60 9.21,614.29,179 9 6,6,6.24.29 2011-02-04,610.15,611.44,606.61,610.98,1550800,610.98 2011-02-03,609.48, 611.45,606.13,610.15,1495100,610.15 2011-02-02,611.00,614.34,607.53,612.00,1760700, 612.00 20ll-02-0l604k49,6l3k35,603kll,6llk04,2745300,6llk04 20ll-0l-3l,603k60,604k47,595k55,600k36 , 2804900,600.36 2011-01-28,619.07,620.36,59 9.76,600.99,4231100,600.99   

< P> In the following code:
  • A dictionary is created, containing the key like 'week_1'
  • Each value is also a word Use
  • with , repeat on the file's file, paras dates using standard library content

    Thus we meet Import

      import time from import time .split ( ',') #get week the_date = datetime.date (* time.strptime (data [0], '% Y-% m-% d') [: 3]) _, Sptah_nmber, Din_anmber = D_dat. Iscalerer () Week = "Week _ {} ". Format (week_number) stock = data [1] if day_ count number limit (1, 6): week [week] [day_number -1] = stock  

    results:

      {'week_4': {4: '619.07'}, 'week_5': {0: '603.60', 1: '604.49', 2: '611.00', 3: '60 9.48', 4: 610.15 '},' week_6 ': {0:' 610.16 '}}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -