Skip to content

A simple parser built using python as part of a hiring process. It supports parser data from CSV & XML to JSON. The project was built in a way that makes it easy to extend to new formats, and easy to add new features.

Samuel-Sorial/Python-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Parser Using Python

A simple parser built using python as part of a hiring process.
Report Bug


Table of Contents
  1. About The Project
  2. Getting Started
  3. Testing
  4. Usage Instructions


About The Project

A simple parser built using python as part of a hiring process. It supports parser data from CSV & XML to JSON. The project was built in a way that makes it easy to extend to a new format, and easy to add new features. I've decided to only use built-in modules in my task, as I wanted to show my algorithmic skills (especially in the XML Parser) alongside my software engineering skills.

Built With


Getting Started

The application is very simple, which means that initializing it won't be a big deal.

Prerequisites

  • Python3

Installation

  1. Clone the repo
git clone https://github.com/Samuel-Sorial/Python-Parser.git
  1. Go to the clone directory
cd Python-Parser

Testing

After initializing the project from the previous section, simply run:

python3 -m unittest discover test

Note: if your default python version is python3, you can only type python instead of python3



Usage Instructions

Parse to json

python3 parser.py <format> <files>
  • Supported formats are:
    • CSV
    • XML
  • Output format: json

Sample xml usage:

python3 parser.py xml ./data/xml/customer1.xml

Sample xml output: customer.json file that contains:

{
  "transaction": {
    "date": "2021-12-07",
    "customer": {
      "name": "Shirish Suchak",
      "address": "1429  Joyce Street",
      "phone": "252-414-7396",
      "units": {
        "vehicle": {
          "make": "Honda",
          "vin_number": "WDBFA63E7RF125264",
          "id": "V1824"
        }
      },
      "id": "ID1011200"
    }
  },
  "file_name": "xml/customer1.xml"
}

Sample csv usage:

python3 parser.py csv ./data/csv/vehicles.csv

Sample xml output: vehicles.json file that contains:

[
  {
    "id": "V3015",
    "make": "Chevrolet",
    "vin_number": "1HGFA16548L016469",
    "owner_id": "ID9857"
  },
  {
    "id": "V2014",
    "make": "Honda",
    "vin_number": "1G6KD57Y46U180996",
    "owner_id": "ID9857"
  },
  {
    "id": "V1475",
    "make": "Ford",
    "vin_number": "2HKYF18575H574967",
    "owner_id": "ID5410"
  },
  {
    "id": "V786",
    "make": "Nissan",
    "vin_number": "2GTEK13M481177784",
    "owner_id": "ID6651"
  }
]

About

A simple parser built using python as part of a hiring process. It supports parser data from CSV & XML to JSON. The project was built in a way that makes it easy to extend to new formats, and easy to add new features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages