GithubHelp home page GithubHelp logo

akira_demoss_solution's Introduction

Overview

The goal of this challenge was to transform the data given in the records.log file into a .csv wtih the following columns: order_id, weight (lbs), volume (in3).

Instructions for Use on Linux Ubuntu

Prerequisites:

1.) Create and activate a new virtual envelope

python3 -m venv coding_challenge 
source ./coding_challenge/bin/activate

2.) Install tkinter

sudo apt-get install python3-tk tk-dev

Implementation

3.) Run the script and follow the propt to select a file to convert

python3 solution.py

usage_example1

Figure 1. When running the script, a file browsing GUI where you can select the file you would like to transform will pop up.

4.) View converted file in same directory as original file

usage_example2

Figure 2. Upon successful conversion, the terminal will print the new file's location which will be in the same directory as the original file

Challenge Reflection

Design

I wanted to make sure that the script was easy and intuitive to use so I designed it in a way that the user could choose the file they wished to transform using a GUI. Additionaly for ease of use I designed the script to output the transformed file in the same path the original file was located. In respect to the low-level design, I designed my functions in a way that could easily be added on to to support different types of file conversions. Finally the column data is stored in a queue which is later popped so that the space complexity is O(1) making my solution easily upgradable to handling multiple files at once.

Problem Solving

The main challenge I faced when writing this script was how to parse the data from the log file in a way that was both simple and intuitive. After recognizing that the log file data was in python dictionary format, I began to look into ways to parse a text dictionary into a python dictionary data structure. I found the simplest way to do this was to use the json library. To convert the given logs file into csv format, my solution first opens the file the user wants to transform. Once open, the file is read line by line. Because each line is a string, it is easily converted into a dictionary data structure using the json.loads() method after simply replacing each instance of the apostrophe character (') with the quotation mark character(") character. Once this was completed it was easy to access each column by indexing through the dictionary. The final result of this allowed me to design a simple function to convert the orders measured in metric to imperial and write the data to a new .csv file.

Summary

Overall I really enjoyed re-familiarizing myself with some of the common challenges that occur when working with data for machine learning. I had a lot of fun with the problem solving and design aspects of this challenge and strongly believe that this excercise will help me with projects I complete in the future.

akira_demoss_solution's People

Contributors

akirademoss avatar

Watchers

 avatar

akira_demoss_solution's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.