Hotel-Data-Converter is a tool which help coverts hotel data from one format to another.
- Supported Formats
- Validations
- Output
- Technologies & Tools
- Command Line Flags
- Setup and Execution
- Testing
- Release
- Extending
- Authors
- Acknowledgments
- License
- Notes
Currently this tool supports:
- Converting
CSV
data format toJSON
format. - Converting
CSV
data format toXML
format.
These are the validation rules the tool applies to each data format its about to convert
- The columns/fields must be up to six
- The column positions matters to get appropriate results:
First column
: NameThird column
: StarsSixth column
: Uri
Name
: The name is considered valid if it only contains UTF-8 charactersStars
: The stars are integers ranging from0
to5
.Uri
: A valid uri must be a full (or absolute) URL. The URL protocols(http or https)
, paths, and parameters(?key1=value1&key2=value2)
are optional, domain names(www.github.com)
are required. some examples of valid url formats:
The converted data formats are outputed in the share/results
folder.
The output files are named according to the timestamp in seconds e.g timestamp-name-of-file-converted.extension
.
The timestamp is derived from the current time when the tool is ran.
For example converting a CSV data
to JSON
and XML
at timestamp 1582824983
will output the following in the share/results
folder:
- 1582824983-
<
name-of-file-converted>
-invalid.csv: this contains csv records that do not pass the csv validation. - 1582824983-
<
name-of-file-converted>
.json - 1582824983-
<
name-of-file-converted>
.xml
This flag is only necessary if you're using the go
commands to run
or build
the program.
file
- the name of the file that's intended to be converted. Ensure the file is in theshare/files
folder.required?
: truedefault
: none.
sort
- to sort the hotel data bystars
. if omitted no sort is applied to the result.allowed values
:ascend
ordescend
required?
: falsedefault
: none.
Operating System: Mac OSX
-
Ensure you have
Go
setup on your local machine- You can also checkout this go installation and setup tutorial
-
Change directory to the root of the project
- On your command-line: run
cd path/to/hotel-data-converter
- On your command-line: run
-
On your command-line: run
go build -o bin/main cmd/app/main.go cmd/app/app.go
-
Create the
share/files
folder at the root of the project if it doesn't exist -
Move the file you want to convert to the
share/files
folder located at the root of the project. -
On your command-line: run
bin/main -file=<
name-of-file-to-convert>
- if you want a sorted result: run
bin/main -file=<
name-of-file-to-convert> -sort=<
allowed-values>
- if you want a sorted result: run
-
Check the
share/results
folder for the converted files.
If you intend to use docker:
- Ensure you have Docker setup on your local machine.
- Ensure you have Docker Compose setup on your local machine.
- Change directory to the root of the project
- On your command-line: run
cd path/to/hotel-data-converter
- On your command-line: run
- Create the
share/files
folder at the root of the project if it doesn't exist - On your command-line: run
docker-compose build
. - Move the file you want to convert to the
share/files
folder located at the root of the project. - Create a
.env
file - reference the.env.sample
file.- add the name of the file to
.env
i.eFILE
=<
name-of-file-to-convert>
- add the name of the file to
- On your command-line: run
docker-compose up
. - Check the
share/results
folder for the converted files.
- Change directory to the root of the project
- On your command-line: run
cd path/to/hotel-data-converter
- For unit test
- On your command-line: run
go test ./tests
- On your command-line: run
- On your command-line: run
- Version 1.0.0
To support more formats conversion, this tool can be extend. Simply go through the folder structure and architecture to see where extensions can be added.
- MIT
- The hotel data structure should be in this format:
- Name
- Address
- Stars
- Contact
- Phone
- URI
- Currently you can only sort the hotel data by
Stars
.