Skip to content

Ralitnyi/File-Converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Format Transformer

A console application designed to transform data files between JSON, XML, and CSV formats.

Capabilities

  • Seamless conversion between JSON, XML, and CSV formats
  • Straightforward command-line interface
  • Clear and informative error reporting
  • Handles tabular data structures

Prerequisites

  • Java version 21+
  • Maven 3.6 or above

Compilation

Execute the following command:

./mvnw clean package

This process generates an executable JAR file located at target/file-converter.jar.

Operation

Run the application using:

java -jar target/file-converter.jar --input <source-file> --output <destination-file>

Command Parameters

Parameter Purpose Mandatory
--input Source file path Yes
--output Destination file path Yes
--help Display usage information No

Sample Data Files

The examples/ directory contains demonstration files:

  • examples/username.csv - Data in CSV format
  • examples/username.json - Data in JSON format
  • examples/username.xml - Data in XML format

Usage Demonstration

Transform CSV to JSON:

java -jar target/file-converter.jar --input examples/username.csv --output result.json

Format Specifications

JSON Format

Accepts and produces arrays of simple objects:

[
  {"id": "789", "name": "Robert", "email": "robert@company.org"},
  {"id": "456", "name": "Jennifer", "email": "jennifer@company.org"}
]

Individual objects are also valid:

{"id": "789", "name": "Robert", "email": "robert@company.org"}

XML Format

<?xml version="1.0" encoding="UTF-8"?>
<records>
  <record>
    <id>789</id>
    <name>Robert</name>
    <email>robert@company.org</email>
  </record>
  <record>
    <id>456</id>
    <name>Jennifer</name>
    <email>jennifer@company.org</email>
  </record>
</records>

CSV Format

id,name,email
789,Robert,robert@company.org
456,Jennifer,jennifer@company.org

Technical Constraints

  • Text-based values: All data elements are handled as text strings during format conversion.
  • Tabular data only: Complex nested objects and arrays are not processed. The tool will indicate an error when such structures are encountered.

Error Handling

Condition Response Message
File unavailable Error: Input file 'path' could not be located
Malformed XML Error: XML parsing failed: message
Unsupported extension Error: File format '.xyz' is not supported
Malformed JSON Error: JSON syntax error detected at line X
Complex data structure Error: Complex nested structures cannot be processed. Use flat data
Missing input parameter Error: Required --input argument not provided
Missing output parameter Error: Required --output argument not provided

Test Execution

Run the test suite with:

./mvnw test

About

CLI utility for converting files between JSON, XML, and CSV formats

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages