GithubHelp home page GithubHelp logo

file-parser's Introduction

File-Parser

parse files with different formats and export data in json format

Output

  • parsed files data export in json format and located on current_working_directory/parsing_result/simple.json
  • if folder parsing_result not found it will be created
  • if file simple.json exist it will overwrite it
  • if file simple.json not exist it will create it

Prerequests

How To Run

  1. clone project from github
git clone https://github.com/BakrFrag/File-Parser
  1. go to inside project file
cd File-Parser
  1. install libraries used in project
pip3 install -r requirements.txt

or

pip3 install xlrd==1.2.0
pip3 install untangle==1.1.1
  1. add executable permission to file parser.py
sudo chmod +x parser.py
  1. if you want to run tests
python3.8 -m unittest
  1. start use parser.py and parse files

Parsing Files

  • script handle arguments from command line
  • in case of csv and xlsx format customers file has to be parsed first
  • files headers must match
  • if exception will parse files happen it will printed on terminal exception like parse files with headers miss match , invalid file or file not exist
  • if files parsed it will return the path to parsing output
  • if xlsx customers has to be in first sheet in first workbook and vehicles has to be in first sheet in second workbook
  • in case of csv format or xlsx format vehicles related to customer extracted by joining vehicle.owner_by == customer.id
  1. to parse xml file
./parser.py xml xml_file.xml
  1. to parse csv file
./parser.py csv customers_file.csv vehicles_file.csv
  1. to parse xlsx workbook
./parser.py xlsx customers_file.xlsx vehicles_file.xlsx

File Structure

  1. parsers directory include parser classes used to parse different file formats like xslsx csv and xml parser_helper include utlity functions used by any parser
  2. tests directory include unittests for parser classess
  3. parser.py handle script arguments and apply right parser on them

Deveopment

  • this script is developed in enviroment with Ubuntu 20.04 relase
  • all file formatted using pep8
  • each method or class include description about it

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.