Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There is a CD available for purchase that contains .jpeg and .gif images of musi

ID: 3573091 • Letter: T

Question

There is a CD available for purchase that contains .jpeg and .gif images of music
that is in the public domain. The CD includes a file consisting of lines containing
the names, then composers of that title, one per line. The name of the piece is
first, then zero or more spaces then a dash (-) character, then one or more spaces,
then the composer’s name. The composer name may be only the last name, an
initial and one name, two names (first and last), or three names (first, middle, and
last). There are a few tunes with “no author listed” as author. In the subsequent
processing, “no author listed” should not be rearranged There is a CD available for purchase that contains .jpeg and .gif images of music
that is in the public domain. The CD includes a file consisting of lines containing
the names, then composers of that title, one per line. The name of the piece is
first, then zero or more spaces then a dash (-) character, then one or more spaces,
then the composer’s name. The composer name may be only the last name, an
initial and one name, two names (first and last), or three names (first, middle, and
last). There are a few tunes with “no author listed” as author. In the subsequent
processing, “no author listed” should not be rearranged. Here is a very abbreviated
list of the titles and authors.
1. Adagio “MoonLight” Sonata - Ludwig Van Beethoven
2. An Alexis - F.H. Hummel and J.N. Hummel
3. A La Bien Aimee - Ben Schutt
4. At Sunset - E. MacDowell
5. Angelus - J. Massenet
6. Anitra’s Dance - Edward Grieg
7. Ase’s Death - Edward Grieg
8. Au Matin- Benj. - Godard

37. The Dying Poet - L. Gottschalk
38. Dead March - G.F. Handel
39. Do They Think of Me At Home - Chas. W. Glover
40. The Dearest Spot - W.T. Wrighton
1. Evening - L. Van Beethoven
2. Embarrassment - Franz Abt
3. Erin is my Home - no author listed
4. Ellen Bayne - Stephen C. Foster

9. Alla Mazurka - A. Nemerowsky

1. The Dying Volunteer - A.E. Muse
2. Dolly Day - Stephen C. Foster
3. Dolcy Jones - Stephen C. Foster
4. Dickory, Dickory, Dock - no author listed

Explanation / Answer

fname = 'input.txt' #change this according to your file name
with open(fname) as f:
    content = f.readlines()
data = []
for line in content:
    line = line.split(' ')
    data.append(line)
values = {}
for line in data:
    index = line.find('-')
    key = ''
    for i in range(0, index):
        key+= line[i]+' '
    key = key[:-1]
    val = ''
    for i in range(index+1, len(line)):
        val += line[i]+' '
    val = val[:-1]
    values[key] = val

Your question is ambiguous. I assumed that you need to read the file into a suitable data structure to be able to use that data further. The code I have provided will create a dictionary of the values and remove white spaces etc from the data.

If there is more to the question, tell me, I'll update the answer.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote