Skip to content

Golder_elt_homework#47

Open
ktegolder wants to merge 2 commits intoHedgeApple:masterfrom
ktegolder:master
Open

Golder_elt_homework#47
ktegolder wants to merge 2 commits intoHedgeApple:masterfrom
ktegolder:master

Conversation

@ktegolder
Copy link
Copy Markdown

	This homework python program takes the homework.csv file and applies transformations to it to create a formatted.csv file. Two python standard library modules of csv and decimal were used. The main function runs first and calls other functions to apply the needed transformations. This program was designed with the ability to quickly modify and include more transformations such as other dimensions, weight conversions, or others not included in homework.csv.

	The beginning of the main function opens the homework.csv file and reads the data using the csv library. Empty lists and a variable are then defined to be used throughout the rest of the function. Next, the for-loop goes through each row that has been read so that select information can be modified. The header row has a unique function of deciding which columns will need edited, so it is picked out by an if statement. Header titles are checked, by calling other functions, to append those with a date, currency, distance/dimension, or UPC to transformation lists. Titles’ column number starting from zero are kept track of and appended to the lists for reference in the data rows. When in the else statement which involves the data rows, column count is kept track of again and used to check against the transformation lists to transform the corresponding data items. Transformed data is lastly added to a list and written to the formatted.csv file.

	The first function of “isData” is called from the header-if statement in the main function and takes a header title. It simply returns true if “date” is in the header title. Similarly, “isCurrency” , “isDistance”, and “isUPC” check for their corresponding key words that were selected by manually scanning/searching through the homework.csv file. All other functions serve their corresponding transformation by taking the data item in and applying the conversion or formatting requested. The “makeISO” function puts dates into ISO format by splitting the date given and formatting it.  Another function, “roundCurrency”, caused some issues in testing with the inconsistent use of dollar signs and commas so those are filtered out to just format the number with two decimal places. Since cubic feet is the only unit of measure used needing conversion to inches, “convertInches3” simply handles this conversion and formatting. Lastly, “convertString” is used exclusively for UPC to be handled as a string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant