View the step-by-step solution to:

The program below is an implementation of a python program that lists 2 pre-set books to search, or accept user data.

The program below is an implementation of a python program that lists 2 pre-set books to search, or accept user data.


presetlist=[["Cather","9910103442003692"],["Turtles","9910728042003692"]]

print('WELCOME TO THE CLICK BOOK SEARCH REQUEST')
print('nPreset Examples:')
id_list=[]
nz_mms_id_list=[]
for i,item in enumerate(presetlist):
    id_list.append(i)
    nz_mms_id_list.append(item[1])
    print('  ',i,item[0])

while True:
    val=input('Please choose a preset example (0-1) or enter your own nz_mms_id: ')

    if len(val)<3:
        if int(val) not in id_list:
            print('X is not an option. Please try again.')
        else:
            print('You chose:',val)
            print('This is what I found:',presetlist[int(val)][0])
    else:
        if len(val)<16:
            print('Invalid nz_mms_id.')
        elif len(val)==16:
            if val not in nz_mms_id_list:
                print('nz_mms_id not found.Please try again.')
            else:
                print('You chose:',val)
                for item in presetlist:
                    if item[1]==val:
                        print('This is what I found:',item[0])
                        break
        else:
            print('Invalid nz_mms_id.')


    choice=input('Would you like to choose another book? ')
    if choice.upper()=='N':
        break


How do i implement a separate script file from the prompt?

l need to read in data from static jscon files attached below and develop the function in a way that i can move towards implementing real API calls.

So this function should do the following:


getData({{location}}) return data[]

Given a location (right now a local file) it should return that file's data in an array.

So right now you should be able to invoke: getData( "../data/get-bib-9910103442003692.json") and return an array with all the data in the file.


get-bib-9910103442003692 - json sourse file

{
    "bib": [
        {
            "mms_id": "991001018139703691",
            "record_format": "marc21",
            "linked_record_id": {
                "value": "9910103442003692",
                "type": "NZ"
            },
            "title": "Writings from Willa Cather's campus years;",
            "author": "Cather, Willa,",
            "issn": null,
            "isbn": null,
            "network_number": [
                ".b10835878",
                "94552",
                "ocm00755984",
                "(MnSST)b10835878-01clic_stthomas",
                "(EXLNZ-01CLIC_NETWORK)9910103442003692"
            ],
            "place_of_publication": "[Lincoln]",
            "date_of_publication": "[1950]",
            "publisher_const": "University of Nebraska Press",
            "holdings": {
                "value": null,
                "link": "https://api-na.hosted.exlibrisgroup.com/almaws/v1/bibs/991001018139703691/holdings"
            },
            "created_by": "import",
            "created_date": "2017-05-23Z",
            "last_modified_by": "System",
            "last_modified_date": "2018-10-19Z",
            "suppress_from_publishing": "false",
            "originating_system": "OTHER",
            "originating_system_id": "b10835878-01clic_stthomas",
            "cataloging_level": {
                "value": "00",
                "desc": "Default Level"
            },
            "anies": [
                "<?xml version="1.0" encoding="UTF-16"?>n<record><leader>01150cam a2200313I  4500</leader><controlfield tag="001">991001018139703691</controlfield><controlfield tag="005">20170616062833.0</controlfield><controlfield tag="008">731206s1950    nbuc          00010deng  </controlfield><datafield ind1=" " ind2=" " tag="010"><subfield code="a">50006537</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(MnSST)b10835878-01clic_stthomas</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">ocm00755984</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">94552</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">.b10835878</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(EXLNZ-01CLIC_NETWORK)9910103442003692</subfield></datafield><datafield ind1=" " ind2=" " tag="040"><subfield code="a">DLC</subfield><subfield code="c">HEI</subfield><subfield code="d">SER</subfield><subfield code="d">MNE</subfield></datafield><datafield ind1=" " ind2=" " tag="049"><subfield code="a">MNE1</subfield></datafield><datafield ind1="0" ind2=" " tag="050"><subfield code="a">PS3505.A87</subfield><subfield code="b">A6 1950</subfield></datafield><datafield ind1=" " ind2=" " tag="082"><subfield code="a">810.81</subfield></datafield><datafield ind1="1" ind2=" " tag="100"><subfield code="a">Cather, Willa,</subfield><subfield code="d">1873-1947.</subfield></datafield><datafield ind1="1" ind2="0" tag="245"><subfield code="a">Writings from Willa Cather's campus years;</subfield><subfield code="c">edited by James R. Shively.</subfield></datafield><datafield ind1=" " ind2=" " tag="260"><subfield code="a">[Lincoln]</subfield><subfield code="b">University of Nebraska Press</subfield><subfield code="c">[1950]</subfield></datafield><datafield ind1=" " ind2=" " tag="300"><subfield code="a">142 p.</subfield><subfield code="b">port.</subfield><subfield code="c">22 cm.</subfield></datafield><datafield ind1=" " ind2=" " tag="500"><subfield code="a">"Letters from Willa Cather's contemporaries": p. [113]-142.</subfield></datafield><datafield ind1=" " ind2=" " tag="690"><subfield code="a">Rare books</subfield><subfield code="9">LOCAL</subfield></datafield><datafield ind1="1" ind2=" " tag="700"><subfield code="a">Shively, James R.,</subfield><subfield code="e">ed.</subfield></datafield><datafield ind1="0" ind2=" " tag="793"><subfield code="a">Rare books</subfield></datafield><datafield ind1=" " ind2=" " tag="902"><subfield code="a">161202</subfield></datafield><datafield ind1=" " ind2=" " tag="907"><subfield code="a">.b10835878</subfield><subfield code="b">multi</subfield><subfield code="c">-</subfield></datafield><datafield ind1=" " ind2=" " tag="945"><subfield code="a">133.43 H553FE</subfield><subfield code="d">  -  -  </subfield><subfield code="e">  -  -  </subfield><subfield code="f">  -  -  </subfield><subfield code="g">1</subfield><subfield code="h">0</subfield><subfield code="i">30513200458251</subfield><subfield code="j">44</subfield><subfield code="t">0</subfield><subfield code="l">bwbk </subfield><subfield code="u">0</subfield><subfield code="v">0</subfield><subfield code="y">.i11490858</subfield><subfield code="z">010709</subfield><subfield code="s">-</subfield></datafield><datafield ind1=" " ind2=" " tag="945"><subfield code="a">PS 3505. A87.A6</subfield><subfield code="d">  -  -  </subfield><subfield code="e">07-20-2012 16:12</subfield><subfield code="f">05-23-2013 8:45</subfield><subfield code="g">1</subfield><subfield code="h">0</subfield><subfield code="i">30516001269785</subfield><subfield code="j">195</subfield><subfield code="t">0</subfield><subfield code="l">tocir</subfield><subfield code="u">1</subfield><subfield code="v">2</subfield><subfield code="y">.i11490883</subfield><subfield code="z">010709</subfield><subfield code="s">-</subfield></datafield><datafield ind1=" " ind2=" " tag="998"><subfield code="b">4</subfield><subfield code="c">000701</subfield><subfield code="d">-</subfield><subfield code="e">b</subfield><subfield code="f">-</subfield><subfield code="g">0</subfield></datafield><datafield ind1=" " ind2=" " tag="INT"><subfield code="a">P</subfield></datafield><datafield ind1=" " ind2=" " tag="INST"><subfield code="a">01CLIC_STTHOMAS</subfield></datafield><datafield ind1=" " ind2=" " tag="AVA"><subfield code="0">991001018139703691</subfield><subfield code="a">01CLIC_STTHOMAS</subfield><subfield code="b">TOSF</subfield><subfield code="c">CLIC General Loan</subfield><subfield code="d">PS 3505. A87.A6</subfield><subfield code="e">unavailable</subfield><subfield code="f">1</subfield><subfield code="g">1</subfield><subfield code="j">CLIC_LONG</subfield><subfield code="k">0</subfield><subfield code="p">1</subfield><subfield code="q">St. Thomas O'Shaughnessy-Frey Library</subfield></datafield></record>"
            ],
            "requests": null,
            "link": null
        }
    ],
    "total_record_count": null
}


get-bib-9910728042003692 - json sourse file

{
    "bib": [
        {
            "mms_id": "991014467478903691",
            "record_format": "marc21",
            "linked_record_id": {
                "value": "9910728042003692",
                "type": "NZ"
            },
            "title": "Turtles all the way down /",
            "author": "Green, John,",
            "issn": null,
            "isbn": "0525555382",
            "network_number": [
                "(OCoLC)ocn992432937",
                "(OCoLC)992432937",
                "(OCoLC)1007172305",
                "(OCoLC)992432938",
                "(OCoLC)991239607",
                "(OCoLC)991090993",
                "(EXLNZ-01CLIC_NETWORK)9910728042003692"
            ],
            "place_of_publication": "New York, NY :",
            "date_of_publication": "[2017]",
            "publisher_const": "Dutton Books, an imprint of Penguin Random House LLC,",
            "holdings": {
                "value": null,
                "link": "https://api-na.hosted.exlibrisgroup.com/almaws/v1/bibs/991014467478903691/holdings"
            },
            "created_by": "01063007######01CLIC_BETHEL",
            "created_date": "2017-11-13Z",
            "last_modified_by": "system",
            "last_modified_date": "2019-01-21Z",
            "suppress_from_publishing": "false",
            "originating_system": "WorldCat (OCLC)",
            "originating_system_id": "ocn992432937",
            "anies": [
                "<?xml version="1.0" encoding="UTF-16"?>n<record><leader>04304cam a2200817 i 4500</leader><controlfield tag="001">991014467478903691</controlfield><controlfield tag="005">20180521121927.0</controlfield><controlfield tag="007">ta</controlfield><controlfield tag="008">171025t20172017nyu    d      000 f eng d</controlfield><datafield ind1=" " ind2=" " tag="010"><subfield code="a">  2017299345</subfield></datafield><datafield ind1=" " ind2=" " tag="019"><subfield code="a">991090993</subfield><subfield code="a">991239607</subfield><subfield code="a">992432938</subfield><subfield code="a">1007172305</subfield></datafield><datafield ind1=" " ind2=" " tag="020"><subfield code="a">9780525555360</subfield><subfield code="q">(hardcover)</subfield></datafield><datafield ind1=" " ind2=" " tag="020"><subfield code="a">0525555366</subfield><subfield code="q">(hardcover)</subfield></datafield><datafield ind1=" " ind2=" " tag="020"><subfield code="a">9780525555384</subfield></datafield><datafield ind1=" " ind2=" " tag="020"><subfield code="a">0525555382</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(OCoLC)992432937</subfield><subfield code="z">(OCoLC)991090993</subfield><subfield code="z">(OCoLC)991239607</subfield><subfield code="z">(OCoLC)992432938</subfield><subfield code="z">(OCoLC)1007172305</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(OCoLC)ocn992432937</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(EXLNZ-01CLIC_NETWORK)9910728042003692</subfield></datafield><datafield ind1=" " ind2=" " tag="040"><subfield code="a">BTCTA</subfield><subfield code="b">eng</subfield><subfield code="e">rda</subfield><subfield code="c">DLC</subfield><subfield code="d">YDX</subfield><subfield code="d">FN4</subfield><subfield code="d">CHILD</subfield><subfield code="d">BLP</subfield><subfield code="d">PBJ</subfield><subfield code="d">UAP</subfield><subfield code="d">JAI</subfield><subfield code="d">CZA</subfield><subfield code="d">OCLCF</subfield><subfield code="d">IGA</subfield><subfield code="d">ILC</subfield><subfield code="d">GTA</subfield><subfield code="d">OSU</subfield><subfield code="d">EHH</subfield><subfield code="d">[email protected]</subfield><subfield code="d">JHWCP</subfield><subfield code="d">BTCTA</subfield><subfield code="d">DMOPL</subfield><subfield code="d">OCL</subfield><subfield code="d">CD5</subfield><subfield code="d">NMW</subfield><subfield code="d">OCLCO</subfield><subfield code="d">IUK</subfield><subfield code="d">TXSME</subfield><subfield code="d">OCLCO</subfield><subfield code="d">TXLVP</subfield><subfield code="d">XFF</subfield><subfield code="d">OCLCO</subfield><subfield code="d">WW9</subfield><subfield code="d">OCL</subfield><subfield code="d">OKS</subfield><subfield code="d">IAC</subfield><subfield code="d">UV0</subfield><subfield code="d">QS5</subfield><subfield code="d">TNX</subfield><subfield code="d">GYG</subfield><subfield code="d">TXSVP</subfield><subfield code="d">CHVBK</subfield><subfield code="d">CZL</subfield><subfield code="d">UAB</subfield><subfield code="d">VBO</subfield><subfield code="d">KJ6</subfield><subfield code="d">IOW</subfield><subfield code="d">UPM</subfield><subfield code="d">GILDS</subfield><subfield code="d">IPL</subfield><subfield code="d">IAS</subfield><subfield code="d">GZW</subfield><subfield code="d">CSA</subfield><subfield code="d">IDU</subfield><subfield code="d">OCLCQ</subfield><subfield code="d">CNO</subfield><subfield code="d">KK2</subfield><subfield code="d">UAT</subfield><subfield code="d">FPJ</subfield><subfield code="d">GZM</subfield><subfield code="d">EZC</subfield><subfield code="d">FYO</subfield><subfield code="d">ST5</subfield><subfield code="d">FPB</subfield><subfield code="d">FJD</subfield><subfield code="d">FYM</subfield></datafield><datafield ind1=" " ind2=" " tag="042"><subfield code="a">lccopycat</subfield></datafield><datafield ind1="0" ind2="0" tag="050"><subfield code="a">PZ7.G8233</subfield><subfield code="b">Tur 2017</subfield></datafield><datafield ind1="0" ind2="4" tag="082"><subfield code="a">[Fic]</subfield><subfield code="2">23</subfield></datafield><datafield ind1=" " ind2=" " tag="084"><subfield code="a">YAF011000</subfield><subfield code="a">YAF058120</
</

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question