Skip to content

arian-khanjani/format-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

format-converter

A simple CLI tool practice to convert various data types to each other.

Features

  • Command Line Tool
  • CSV to JSON

Run

To run the project (convert CSV to JSON):

// without pretty flag
go run main.go csv [file-path-to-be-converted]

// with pretty and separator flags
go run main.go csv --pretty=true --separator=semicolon [file-path-to-be-converted]
go run main.go csv -pretty=true -s=semicolon [file-path-to-be-converted]

Example

Input (cities.csv):

LatD, LatM, LatS, NS, LonD, LonM, LonS, EW, City, State
   41,    5,   59, "N",     80,   39,    0, "W", "Youngstown", OH
   42,   52,   48, "N",     97,   23,   23, "W", "Yankton", SD
   46,   35,   59, "N",    120,   30,   36, "W", "Yakima", WA
   42,   16,   12, "N",     71,   48,    0, "W", "Worcester", MA

Output (cities-pretty.json):

[
   {
      "City": "Youngstown",
      "EW": "W",
      "LatD": "41",
      "LatM": "5",
      "LatS": "59",
      "LonD": "80",
      "LonM": "39",
      "LonS": "0",
      "NS": "N",
      "State": "OH"
   },
   {
      "City": "Yankton",
      "EW": "W",
      "LatD": "42",
      "LatM": "52",
      "LatS": "48",
      "LonD": "97",
      "LonM": "23",
      "LonS": "23",
      "NS": "N",
      "State": "SD"
   },
   {
      "City": "Yakima",
      "EW": "W",
      "LatD": "46",
      "LatM": "35",
      "LatS": "59",
      "LonD": "120",
      "LonM": "30",
      "LonS": "36",
      "NS": "N",
      "State": "WA"
   },
   {
      "City": "Worcester",
      "EW": "W",
      "LatD": "42",
      "LatM": "16",
      "LatS": "12",
      "LonD": "71",
      "LonM": "48",
      "LonS": "0",
      "NS": "N",
      "State": "MA"
   }
]

TODO

  • JSON to CSV (maybe)
  • XML support
  • ESR support

About

A simple CLI tool to convert one format to another

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages