Difference between revisions of "Spreadsheet To Dictionaries Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 2: Line 2:
 
=Inspiration=
 
=Inspiration=
 
The aggressively helpful Ruby libraries which support [https://ruby-doc.org/stdlib-2.6.3/libdoc/csv/rdoc/CSV.html CSV] parsing to hashes with headers as keys.
 
The aggressively helpful Ruby libraries which support [https://ruby-doc.org/stdlib-2.6.3/libdoc/csv/rdoc/CSV.html CSV] parsing to hashes with headers as keys.
 +
=Code To Use=
 +
==[[Spreadsheet_Assignment|Spreadsheet]] Exercise==
 +
==[[Chained_Dictionary_Assignment|SingleChainedDictionary]]==
 +
==[https://smlfamily.github.io/Basis/list.html List]==
 +
==[https://smlfamily.github.io/Basis/list-pair.html ListPair]==
  
 
=Code To Implement=
 
=Code To Implement=

Revision as of 05:21, 19 October 2022

Follows Spreadsheet and Chained Dictionaries exercises.

Inspiration

The aggressively helpful Ruby libraries which support CSV parsing to hashes with headers as keys.

Code To Use

Spreadsheet Exercise

SingleChainedDictionary

List

ListPair

Code To Implement

structure SpreadsheetToDictionaries

to_dictionaries_using_headers_as_keys

fun to_dictionaries_using_headers_as_keys(s : sheet) : (cell,cell) SingleListDictionary.dictionary list =
       raise NotYetImplemented

Given this spreadsheet:

Name Uniform Number Birth Year Games Played Goals Assists
Bobby Orr 4 1948 657 270 645
Wayne Gretzky 99 1961 1487 894 1963
Mario Lemieux 66 1965 915 690 1033

to_dictionaries_using_headers_as_keys should return a list with 3 single list dictionaries, one for each non-header row. The dictionaries would be filled with entries for each column, using the cell in the header of the column as the key and the cell in the particular row of the column as the value.

[ { TEXT("Name") => TEXT("Bobby Orr"),     TEXT("Uniform Number") => INTEGER(4),  TEXT("Birth Year") => INTEGER(1948), TEXT("Games Played") => INTEGER(657),  TEXT("Goals") => INTEGER(270), TEXT("Assists") => INTEGER(645)  }, 
  { TEXT("Name") => TEXT("Wayne Gretzky"), TEXT("Uniform Number") => INTEGER(99), TEXT("Birth Year") => INTEGER(1961), INTEGER("Games Played") => INTEGER(1487), TEXT("Goals") => INTEGER(894), TEXT("Assists") => INTEGER(1963) }, 
  { TEXT("Name") => TEXT("Mario Lemieux"), TEXT("Uniform Number") => INTEGER(66), TEXT("Birth Year") => INTEGER(1965), INTEGER("Games Played") => INTEGER(915),  TEXT("Goals") => INTEGER(690), TEXT("Assists") => INTEGER(1033) } ]

NOTE: you can assume that you will not be passed the empty list. If you want to handle this case anyway, raising Empty seems like a reasonable thing to do.

Testing

source folder: src/test/sml/spreadsheet_to_dictionaries
how to run with CM.make verbosity off: sml -Ccm.verbose=false run_spreadsheet_to_dictionaries_testing.sml
how to run with CM.make verbosity on: sml run_spreadsheet_to_dictionaries_testing.sml

note: ensure that you have removed all printing to receive credit for any assignment.

SML Error Messages