Code Monkey home page Code Monkey logo

csvtoxmljava's Introduction

CSV to XML Converter

Assumptions:

  1. CSV file first line is the headers. example: Name,Phone,Address
  2. Following lines are individual records example: ABC,12345,Comm St
  3. Currently Main class calls convertToXML function with input and output file name. Input file sample.csv is present in src folder. Output file finalXML.xml generated in project. If file not visible in project explorer, please refresh.

Dependencies: All dependencies can be found in the project. This project was written on a MacOS machine on intelliJ primarily, but then migrated to Eclipse for easy distribution.

Class Description: Main - Driver class for project. Calls convertToXML function with i/p and o/p file name.

Converter - Converts the input csv to xml. The convertToXML method returns a boolean for file conversion. If file conversion unsuccessful, Error is displayed.

ConverterTest - JUnit test cases for Converter.

  1. testConvertToXML()
    • checks successful conversion of correct csv file to xml.
    • generated file compared to expected file using compareFiles function.
    • compareFile utility compares files by converting them to string and hashing.
  2. testFileFormatWrong()
    • Checks for wrong file format files.
    • Error is displayed and file conversion Aborted.
  3. testFileIsEmpty()
    • Checks for empty file.
    • Error is displayed and file conversion Aborted.
  4. testFileDoesNotExist()
    • Checks for file that does not exist.
    • Error is displayed and file conversion Aborted.
  5. testHeaderNoValue()
    • Checks for file where no matching value is found for a tag.
    • Warning displayed and NA added to tag.
  6. testValueNoHeader()
    • Checks for file where a record has more values than tag names.
    • Warning displayed and extra values are not added to xml.

Future Version

  1. Allow user to pick input file from a browser like utility or Paste CSV as text.
  2. Allow user to enter output file name and select location when file conversion complete.
  3. XSLT to make XML better aligned.
  4. Allow user to select splitter.(',','#',':')
  5. Allow user to sort which header displays first in XML. (example: Name,Address,ID) become
  6. Allow user to skip certain values in csv (example: Name,Address,Phone) user can skip Address
  7. Allow user to decide what to do with empty values.

csvtoxmljava's People

Contributors

nivedita2015 avatar

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.