Repository navigation
Expand file tree
/
Copy pathPracticeReadingCSVData.rtf
More file actions
73 lines (69 loc) · 8.34 KB
/
Copy pathPracticeReadingCSVData.rtf
File metadata and controls
73 lines (69 loc) · 8.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{\rtf1\ansi\ansicpg1252\cocoartf2513
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;\f1\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;\red46\green45\blue42;\red255\green255\blue255;\red31\green36\blue45;
\red60\green184\blue123;\red63\green69\blue80;\red13\green100\blue126;\red245\green246\blue249;}
{\*\expandedcolortbl;;\cssrgb\c23529\c23137\c21569;\cssrgb\c100000\c100000\c100000;\cssrgb\c16078\c18824\c23137;
\cssrgb\c27451\c76078\c55686;\cssrgb\c31373\c34118\c38824;\cssrgb\c0\c46667\c56863;\cssrgb\c96863\c97255\c98039;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{none\}.}{\leveltext\leveltemplateid1\'01.;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{none\}}{\leveltext\leveltemplateid101\'00;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid2}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}}
{\info
{\author Elisabeth Robson}}\margl1440\margr1440\vieww19520\viewh25200\viewkind0
\deftab720
\pard\pardeftab720\sl920\partightenfactor0
\f0\fs72 \cf2 \cb3 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 Do the Work: Practice Reading CSV Data\
\pard\pardeftab720\sa400\partightenfactor0
\fs36 \cf2 In a previous lesson you learned how we can read data from a CSV file using D3, creating an array of objects made out of each line of data in the CSV.\cb1 \
\cb3 You also learned that D3 automatically uses the headings in the first row of the CSV file as the properties for each entry in the data (CSV is comma separated values, so each entry is separated by a comma on a line of data).\cb1 \uc0\u8232 \
\cb3 Write some D3 code to read in the attached file (Icecream.csv) and create an array of objects containing the ice cream data. Display the array you create in the console, and it should look like this:\cb1 \
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl340\partightenfactor0
\ls1\ilvl0
\f1\fs24 \cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 0:\{year: 2000, pounds: 3422, topSeller: \cf5 \strokec5 "Strawberry"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "NJ"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 1:\{year: 2001, pounds: 3597, topSeller: \cf5 \strokec5 "Strawberry"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "NY"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 2:\{year: 2002, pounds: 3619, topSeller: \cf5 \strokec5 "Vanilla"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "NY"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 3:\{year: 2003, pounds: 3971, topSeller: \cf5 \strokec5 "Vanilla"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "CA"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 4:\{year: 2004, pounds: 4103, topSeller: \cf5 \strokec5 "Chocolate"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "CA"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 5:\{year: 2005, pounds: 4008, topSeller: \cf5 \strokec5 "Strawberry"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "FL"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 6:\{year: 2006, pounds: 4554, topSeller: \cf5 \strokec5 "Chocolate"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "NY"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 7:\{year: 2007, pounds: 4633, topSeller: \cf5 \strokec5 "Vanilla"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "NY"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 8:\{year: 2008, pounds: 3190, topSeller: \cf5 \strokec5 "Strawberry"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "CA"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 9:\{year: 2009, pounds: 2951, topSeller: \cf5 \strokec5 "Mint Chocolate Chip"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "PA"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 10:\{year: 2010, pounds: 3004, topSeller: \cf5 \strokec5 "Pistachio"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "NC"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 11:\{year: 2011, pounds: 3092, topSeller: \cf5 \strokec5 "Chocolate Chip"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "FL"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 12:\{year: 2012, pounds: 3803, topSeller: \cf5 \strokec5 "Chocolate"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "CA"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 13:\{year: 2013, pounds: 3922, topSeller: \cf5 \strokec5 "Chocolate"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "CA"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 14:\{year: 2014, pounds: 4133, topSeller: \cf5 \strokec5 "Vanilla"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "FL"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 15:\{year: 2015, pounds: 4219, topSeller: \cf5 \strokec5 "Vanilla"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "NY"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 16:\{year: 2016, pounds: 2382, topSeller: \cf5 \strokec5 "Mint Chocolate Chip"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "CA"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\ls1\ilvl0\cf4 \cb3 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\listtext . }\expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec4 17:\{year: 2017, pounds: 2133, topSeller: \cf5 \strokec5 "Mint Chocolate Chip"\cf4 \strokec4 , maxStatePerCapita: \cf5 \strokec5 "FL"\cf4 \strokec4 \}\cf6 \cb1 \strokec6 \
\pard\pardeftab720\sa400\partightenfactor0
\f0\fs36 \cf2 \cb3 \strokec2 Make sure you handle the cases where elements might be empty and use 0 for the numbers, and empty string ("") for the strings in case they are empty. Convert the strings that contain numbers into numbers.\cb1 \
\cb3 Extra Credit: Can you use JavaScript to find the year that had the maximum pounds of ice cream sold?\cb1 \
\cb3 (Note: all data values completely made up by me. It is a fact that I do love ice cream, however).\cb1 \
\pard\pardeftab720\partightenfactor0
\fs48 \cf2 \cb3 Resources for this lecture\cb1 \
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
\ls2\ilvl0
\fs40 \cf7 \cb8 \kerning1\expnd0\expndtw0 \outl0\strokewidth0 {\field{\*\fldinst{HYPERLINK "javascript:void(0)"}}{\fldrslt \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec7 Icecream.csv}}\cf2 \cb1 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
}