I know this forum isn't to give away the answers, but could someone maybe help me get started? My biggest problem is figuring out where to start. Even the pseudo code doesn't help me very much. I don't know how to use an excel file in a program either. I would include the file but I cant upload a .csv file. Any help would be appreciated.


“StateQuarters.csv” contains the dates that quarters celebrating the statehood of each of thee 50 states were issued by the US mint(alphabetized by state name) and the date that state was admitted to statehood. Notice that the dates in the two columns are not in the same format. Your code must adjust for that as necessary. Caution: if you look at this data using a spreadsheet, the spreadsheet may alter the way that some or all of the dates are displayed for you. You must view the unchanged data in a text editor to see what is really there.

Your program should contain at least a main function and at least one other function and should produce the printed output listed below. There should be exactly one blank line between the output for each of the 5 sub-assignments below and one state, month, or answer per line for each sub-assignment. The results must be printed in the order designated below.

1. Print the states whose names are 11 or more characters in length.
2. Print alphabetically, the states that became states in March (of any year).
3. Print the states whose names begin with ‘N’ and their statehood dates.
4. Are there months of the year in which no new quarters were issued? Print them.
5. Some states quarters were issued in the same month as their statehood data. Print these states names sorted in the order that they achieved statehood.
To assist you in implementing this program, I have provided this pseudo-code that contains the major steps that you must implement.

PA 5 Pseudocode
0. Read file, strip lines, split lines on commas, create list of lists or tuples, etc.
1. Process the list printing the state name if its length is >=11
2. Process the list printing the state name if statehood date contains ‘Mar’
3. Process the list printing the state name and statehood date if state name begins with ‘N’
4. Print months when no quarters were issued.
a. Create list of month abbreviations
b. Create list of 12 accumulators
c. Process the list, examine the issue month and increment the appropriate accumulator
d. Print the months corresponding to accumulators that remain zero
5. Print state names where the month of the quarter issue and the month of statehood are the same.

a. Normalize all dates in the list to yyyymmdd format
b. Select states where issue month and statehood month are identical and for the matches, create list of tuples: (normalizedStatehoodDate, stateName)
c. Sort the list above
d. Print just the state name from this sorted list

Useful functions to consider writing include:
file2list, printLong, printMarch, printNs, monthAccumulator, normalizeDate, main

Recommended Answers

All 3 Replies

My biggest problem is figuring out where to start. Even the pseudo code doesn't help me very much

PA 5 Pseudocode
0. Read file, strip lines, split lines on commas, create list of lists or tuples, etc.
1. Process the list printing the state name if its length is >=11

Either you are stupid and aren't able to Google for these simple tasks, or you are calling us stupid. Please read this thread http://www.daniweb.com/software-development/computer-science/threads/573

Here is what I have so far, the second function doesnt work but I think I am close.

def longState(csvReader):
	states = ''
	for line in csvReader:
		state = line[0]
		if len(state) > 10:
			states = states + state + "\r"
	return states
		
def march(csvReader):
	states = ''
	for line in csvReader:
		month = line[2]
		state = line[0]
		month=month.split("-")
		if 'Mar' in month:
			states = states + state
	return states

def main():
	import csv
	fObj = open ('StateQuarters.csv', 'rU')
	csvReader = csv.reader(fObj)
	print longState(csvReader)
	print march(csvReader)
	
main()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.