ࡱ> TVS bjbjGG 1(--V V &&&&&::::N$:2r(ccc!2#2#2#2#2#2#2,@57\O2&cccccO2&&d2cf&&!2c!2A01p 0 2z2021N8N801&10cccO2O2ccc2N8cccccccccV :   CSE 231 Spring 2013 Programming Project 06 This assignment is worth 40 points (4.0% of the course grade) and must be completed and turned in before 11:59 on Monday, Feb 25th. Two weeks because of the midterm!!! Assignment Overview The goal of this project is to gain more practice with file I/O, lists and functions. Background Data mining is the process of sorting through large amounts of data and picking out relevant information. It is usually used by everyone from financial analysts to scienstist to extract information from the enormous data sets. These large data sets and the trend of analyzing them has come to be know as "Big Data"  HYPERLINK "http://en.wikipedia.org/wiki/Big_data" http://en.wikipedia.org/wiki/Big_data In this project, we want to do some preliminary data mining of the prices of Apple stock. Your program will calculate the monthly average prices of Apple stock from 1984 to 2013. You will report facts about the monthly highs and lows for this data. Project Specifications A file of Apple's daily stock's prices will be given to you, whose name is table.csv. This file could be opened by notepad or similar text editor, and is delimited by commas. If you open it with Excel, it will show you the data as a spreadsheet. You must implement the following functions: a. get_input_descriptor() In this function, you are required to repeatedly prompt for the name of an input file until the user enters filename and the file can be opened for input. Return a file descriptor attached to the opened file. b. get_data_list(file_object, column_number) In this function, you are required to read the file of Apple's data. The function is flexible as it can read the data for any column of the data (0 through 6). If you read column 6, you are gathering the data for the "Adjusted Daily Close". If you read column 5, you are gathering data for the "Volume" that day. The function returns a list that consists of tuples. Each tuple is of the form: (date, column_data). For example: ('2013-02-08', 474.98) if we were collecting data from column 6. c. average_data(list_of_tuples) In this function, take in an argument that is the list of tuples generated by get_data_list above. You will average the data for each month, and regenerate a list of tuples. A tuple here will have the form: (data_avg, date). For example: (2972945.4545454546, '07:1985') . Note the date does not contain a day any more. d. main() In this function, you: call get_input to get a file descriptor prompt for the column to average call the get_data function call the average_data function print the highest 6 averages (for the column selected) and the lowest 6 averages. Print that data with the month-year information. Deliverables proj06.py your source code solution (remember to include your section, the date, project number and comments). Please be sure to use the specified file name, ie. proj06.py Save a copy of your file in your CSE account disk space (H drive on CSE computers). You will electronically submit a copy of the file using the handin program:  HYPERLINK "http://www.cse.msu.edu/handin/webclient"http://www.cse.msu.edu/handin/webclient List of Files to Download table.csv Assignment Notes: When reading the input file, you should be careful about the first line which does not contain any data. Remember the split() function, which takes as an argument the character to split on, and returns a LIST of STRINGS Dont forget to convert each string stat to a number. Since there are so many fields, do some testing (E.g. output some parsed data) to make sure that you get the correct data. The sorted function should be useful. my_list = [ (3,2), (1,2), (2,5)] sorted_list = sorted(my_list) # sorted_list will be [(1,2), (2,5), (3,2)], sorts on first value in each tuple Remember to close your files after you have opened them file_obj.close() # Very important to close the file! To create a tuple, remember you just use a comma, so a 2-item tuple could be created like this: my_tuple = x,y When you store your date and monthly average, it would probably be easiest to store the date in a string already properly formatted, e.g. 11-2007. To append this tuple to a list you can just say my_list.append(my_tuple). Then to access the different items in the tuple you index into the list twice, so for example if you appended the above tuple as the first item in a list: my_list[0][0] would return x my_list[0][1] would return y Example Output In [121]: main() Open what file:fred Bad file name, try again Open what file:irving Bad file name, try again Open what file:table.csv What column:6 Lowest 6 for column 6 Date:08-1985, Value: 1.70 Date:09-1985, Value: 1.77 Date:06-1985, Value: 1.84 Date:10-1985, Value: 1.90 Date:07-1985, Value: 1.93 Date:11-1985, Value: 2.19 Date:05-1985, Value: 2.21 Highest 6 for column 6 Date:09-2012, Value:674.54 Date:08-2012, Value:635.39 Date:10-2012, Value:628.17 Date:04-2012, Value:597.19 Date:07-2012, Value:592.33 Date:03-2012, Value:569.11 =TU i j u "  F G KQ_~_89mnoɹѴ{u hw]F0Jjhw]FU hw]F5\hhw]F\ hq\hshw]F\ hh\h2 h2 \ h2 \ hw]F\h KFhw]F0J h]Thw]Fjhw]FU hw]F5h]Thw]F5H*aJ hw]F5aJ hw]FaJhw]Fh[ 5CJ aJ h[ .=TU  i j u v   " #   F G 4 h@&^hgd2 gd2 h^hgd2  & F gd2 gdw]F @&gdw]F$a$ $@&a$gdw]F45bPQq6UW8^ & F @&gdw]F & F8@&^8gd2 h^hgd2 h@&^hgd2 UYh ~h ~OJQJ^J h ~5hqhMhw]F5hw]F hw]F5 9^Qp [$\$gdw]F[$\$^gdw]Fp[$\$^pgdw]F & F[$\$gdw]F^gdw]F & Fgdw]F@&gdw]Fgdw]F,ESi &'>Ytgd ~gdw]F @&[$\$gdw]F/1h;0/ =!"#`$`% DyK yK Phttp://www.cse.msu.edu/handin/webclient666666666vvvvvvvvv66666686666666666666666666666666666666666666666666666666hH6666666666666666666666666666666666666666666666666666666666666666666666666662 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~_HmH nH sH tH D`D Normal*$CJ_HaJmH sH tHDA D Default Paragraph FontViV  Table Normal :V 44 la (k (No List 2o2 WW8Num2z0OJQJ6o6 WW8Num2z1 OJQJ^J2o2 WW8Num2z2OJQJDA !D Default Paragraph Font6U`16 Hyperlink >*B* phFV`AF FollowedHyperlink >*B* ph:/Q: Numbering SymbolsNOrN Heading x$CJOJPJQJ^JaJ4B@r4 Body Text5\$/q$ ListD"@D Caption xx $6CJ]aJ** Index $DZ@D Plain TextCJOJQJ^JaJR^@R Ib Normal (Web)dd*$[$\$ PJnHtHRY@R  i Document Map-D M OJQJ^JPK!pO[Content_Types].xmlj0Eжr(΢]yl#!MB;.n̨̽\A1&ҫ QWKvUbOX#&1`RT9<l#$>r `С-;c=1g~'}xPiB$IO1Êk9IcLHY<;*v7'aE\h>=^,*8q;^*4?Wq{nԉogAߤ>8f2*<")QHxK |]Zz)ӁMSm@\&>!7;wP3[EBU`1OC5VD Xa?p S4[NS28;Y[꫙,T1|n;+/ʕj\\,E:! t4.T̡ e1 }; [z^pl@ok0e g@GGHPXNT,مde|*YdT\Y䀰+(T7$ow2缂#G֛ʥ?q NK-/M,WgxFV/FQⷶO&ecx\QLW@H!+{[|{!KAi `cm2iU|Y+ ި [[vxrNE3pmR =Y04,!&0+WC܃@oOS2'Sٮ05$ɤ]pm3Ft GɄ-!y"ӉV . `עv,O.%вKasSƭvMz`3{9+e@eՔLy7W_XtlPK! ѐ'theme/theme/_rels/themeManager.xml.relsM 0wooӺ&݈Э5 6?$Q ,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-!pO[Content_Types].xmlPK-!֧6 -_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!!Z!theme/theme/theme1.xmlPK-! ѐ'( theme/theme/_rels/themeManager.xml.relsPK]#  (4 8 n XX8@0(  0 # $J^8EFQS`T`aoA I $ , ? K ' - Q_qx6D17WJM8;/?T[}   6 : U Z   F L Qqs :DPRQXlsx{::::::::::::::::::::::::::::::::::::: uH2&H m8$F*BQGHEP֜vu\Kcsqptɶ^`.88^8`.^`.^`.pp^p`.  ^ `.@ @ ^@ `.  ^ `.^`.^`^`^`^`^`^`^`^`^`h h^h`hH.h 8^8`hH.h L^`LhH.h  ^ `hH.h  ^ `hH.h xL^x`LhH.h H^H`hH.h ^`hH.h L^`LhH.h h^h`hH.h 8^8`hH.h L^`LhH.h  ^ `hH.h  ^ `hH.h xL^x`LhH.h H^H`hH.h ^`hH.h L^`LhH.h^`OJQJo(hHh^`OJQJ^Jo(hHohp^p`OJQJo(hHh@ ^@ `OJQJo(hHh^`OJQJ^Jo(hHoh^`OJQJo(hHh^`OJQJo(hHh^`OJQJ^Jo(hHohP^P`OJQJo(hHh h^h`hH.h 8^8`hH.h L^`LhH.h  ^ `hH.h  ^ `hH.h xL^x`LhH.h H^H`hH.h ^`hH.h L^`LhH.^`o(. ^`hH. pLp^p`LhH. @ @ ^@ `hH. ^`hH. L^`LhH. ^`hH. ^`hH. PLP^P`LhH.h^h`o(. 8^8`hH. L^`LhH.  ^ `hH.  ^ `hH. xL^x`LhH. H^H`hH. ^`hH. L^`LhH.h^`OJQJo(hHh^`OJQJ^Jo(hHohp^p`OJQJo(hHh@ ^@ `OJQJo(hHh^`OJQJ^Jo(hHoh^`OJQJo(hHh^`OJQJo(hHh^`OJQJ^Jo(hHohP^P`OJQJo(hH EPcsqp m8*BQGu2&u\                                              [ w]F ~2 qh@YYYY`@Unknown G*Ax Times New Roman5Symbol3 *Cx Arial? *Cx Courier New;WingdingsO&Nimbus Sans LArial_ DejaVu SansTimes New Roman;SimSun[SO5 *[`)TahomaACambria MathBAh['zz  $ $24 3QHP(?|2! xx ,CSE 231stredwic Bill Punch0          Oh+'0!  4 @ L Xdlt|'CSE 231 stredwic Normal.dotm Bill Punch5Microsoft Macintosh Word@e@\# @p|@ G PICT b HHb bHHbb-kZg9^skZkZo{ wckZo{kZskZco{kZ-swg9{o{sw {^kZsg9co{o{ss's{wo{{w{{;NsNsZRcZF1^BZNsNsRsF1F1Z^RZZRVJRF1=cwkZZF1ZkZ^Rg9RcZZF1sckZo{^Nsg9^g9o{g9Z{{wo{o{{{{{so{w{{{sso{{s{ws{s{wo{wo{swswkZg9VkZZZ^VRVRVkZ^sVZ^Zo{Vo{VZVVg9kZcg9,^kZRg9cZZVVkZVZV^o{RRg9VZZ^g9Rg9VF1F1=F1RVF1cJRF1cF1JRRF1RcBco{wwo{wsww{o{{{wsco{ws{{{{ww{{s{w{5NsNsJRNsVs^VZJRcNsVZJRNsF1BNs^{NsZBsNskZwwZJRRg9ZNsF1Vo{BNsRF1RNsg9JRg9F1F1o{F1NsF1BRZkZO{{ {{{{w{{w{w{{{{{{{(o{cg9kZg9o{g9o{cZskZkZg9g9o{+sZZRRZZcVo{kZg9^co{cg9c?o{sww{w {w{s{w{o{sws{} kZg9RkZVZZkZZkZVRg9RZ^o{cZkZVZVkZRVZ^ZZR^Z^sV kZg9RkZkZcwZcRo{RVkZVZ^R^{#{{{{s{ VV^Rg9^^ZZR{޳o{g9ckZZkZkZg9o{o{swws w{w{g9w{sww{wwo{wwo{o{wwkZww{kZ{o{sw{{swo{{{o{wo{s{wwo{swo{ssw{wswsswwswkZc#kZ^c^^kZg9wcZkZckZcc^sg9o{ZckZ^Vo{cg9cZZsg9^Vg9g9ckZZco{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o{co{s{so{sww{o{{ssww{wo{wo{{o{so{wo{ kZo{o{g9swkZkZso{so{sso{ww%s{o{{{s{{{{5 cwV^ZZVco{ZVV^wcskZNsVVco{iwwwsw{ww{{wwswwswwwo{VkZVVcg9VRR^VckZVV^ccZVkZV2RNsRg9VZRkZcZVo{Z^g9^kZVNsZVsRNsZVZRZ^^kZV^kZkZNsVg9kZZ^^VZg9^c^V]w{{{{s{so{{ {o{w{{w{{{^kZZs^g9c>wV^o{^Zg9kZco{c^co{^c^^Zw^ckZ^g9c^ccZg9kZkZg9ZsZkZc^^ccw^^ZkZZg9^wZkZZg9Zg9g9kZZkZ{{w{{wwkZkZwssww{w{w{ww{wsw{wkZo{w {{ww{w{wo{ww{wkZ{w{w{s{w{ww^kZg9o{ss^kZswkZkZco{g9g9Zo{so{o{g9csskZZg9kZVc^g9wZg9o{g9VckZwwZo{g9wZkZwcg9o{o{g9kZskZkZo{o{ swo{g9o{o{so{cskZ8o{{wo{wo{o{g9o{co{wso{w{o{wswswswswswso{{s{wwss{w{so{kZ{kZkZwkZkZo{skZo{sso{w+wwo{ssww{g9w{ss{o{wsw+kZg9^^csg9o{Zcwc^{ccg9g9w{޲R{VRVNskZ{{w'Zo{ZckZkZc^^g9co{sg9co{"s{w{swswws{wA kZskZsso{{so{ ss{so{wwkZkZ{kZsso{s{C{wkZcsVcskZZccsg9kZZkZkZskZ^scg9g9kZ^cg9 ՜.+,D՜.+,, hp  'Michigan State University$  CSE 231Programming Project 06Assignment OverviewQThe goal of this project is to gain more practice with file I/O, lists and funct BackgroundProject SpecificationsQa. get_input_descriptor() In this function, you are required to repeatedly promp-b. get_data_list(file_object, column_number) c. average_data(list_of_tuples) d. main()In this function, you:(call get_input to get a file descriptor!prompt for the column to averagecall the get_data functioncall the average_data functionQprint the highest 6 averages (for the column selected) and the lowest 6 averages DeliverablesList of Files to DownloadAssignment Notes: Title HeadingsP 8@ _PID_HLINKS'A d(http://www.cse.msu.edu/handin/webclient &http://en.wikipedia.org/wiki/Big_data  !"#$%&'()*+,-./0123456789;<=>?@ABCDEFGHIJLMNOPQRURoot Entry F> WData 1Table~8WordDocument1(SummaryInformation(:!DocumentSummaryInformation8KCompObj` F Microsoft Word 97-2004 DocumentNB6WWord.Document.8