diff --git a/Scripts/Miscellaneous/json2yaml/README.md b/Scripts/Miscellaneous/json2yaml/README.md new file mode 100644 index 000000000..925d25242 --- /dev/null +++ b/Scripts/Miscellaneous/json2yaml/README.md @@ -0,0 +1,29 @@ +# Python script that provides the download and upload speed of your Wifi + +A simple Python script that uses 'pyyaml' module to conver an input json file into a output yaml file. + +### Prerequisites + +You will need to install pyyaml. +The installation commands are provided in requirements.txt + +### How to run the script + +First you have to go to the json2yaml directory. Run the following command once you are in project directory + +```bash + cd Scripts/Miscellaneous/json2yaml +``` + +For Python 3: +```bash + python json2yaml.py jsonFilePath yamlFilePath +``` + +### Screenshot/GIF showing the sample use of the script + +![Screenshot](Screenshot.png) + +## *Author Name* + +David Mendoza \ No newline at end of file diff --git a/Scripts/Miscellaneous/json2yaml/Screenshot.png b/Scripts/Miscellaneous/json2yaml/Screenshot.png new file mode 100644 index 000000000..5c13dbe08 Binary files /dev/null and b/Scripts/Miscellaneous/json2yaml/Screenshot.png differ diff --git a/Scripts/Miscellaneous/json2yaml/json2yaml.py b/Scripts/Miscellaneous/json2yaml/json2yaml.py new file mode 100644 index 000000000..a85effaae --- /dev/null +++ b/Scripts/Miscellaneous/json2yaml/json2yaml.py @@ -0,0 +1,36 @@ +from json import load +from yaml import dump +from sys import argv + +# validated the ammout of args passed from the command line, so I could get the path from both files before starting the script +def getInputAndOutputFiles(): + if len(argv) ==1: + jsonPath = input("please enter the path to your JSON file: ") + yamlPath = input("please enter the path to your YAML file: ") + elif len(argv) == 2: + jsonPath = argv[1] + yamlPath = input("please enter the path to your YAML file: ") + elif len(argv) >= 3: + jsonPath = argv[1] + yamlPath = argv[2] + return jsonPath,yamlPath + +print("started to convert your file...") +jsonPath,yamlPath = getInputAndOutputFiles() + +# from line 24 to 26 +# I opened the json file +# after that I load the json string into a real python dict +def getJSONValueFromFile(jsonPath): + with open(jsonPath, "r") as jsonFile: + return load(jsonFile) + +if __name__ == "__main__": +# I opened (and created if not done) the yaml destination file +# after that I dumped the dict into the yamlFile through pyyaml +# after that I closed the csv file + jsonValue = getJSONValueFromFile(jsonPath) + yamlFile = open(yamlPath, "w") + dump(jsonValue, yamlFile) + yamlFile.close() + print(f"done, your file is now on {yamlPath}") diff --git a/Scripts/Miscellaneous/json2yaml/requirements.txt b/Scripts/Miscellaneous/json2yaml/requirements.txt new file mode 100644 index 000000000..e4cf41e3d --- /dev/null +++ b/Scripts/Miscellaneous/json2yaml/requirements.txt @@ -0,0 +1 @@ +pyyaml==5.3.1 \ No newline at end of file diff --git a/Scripts/Miscellaneous/json2yaml/test.json b/Scripts/Miscellaneous/json2yaml/test.json new file mode 100644 index 000000000..0e1b67367 --- /dev/null +++ b/Scripts/Miscellaneous/json2yaml/test.json @@ -0,0 +1,515 @@ +[ + { + "_id": "5f755f4445586ec915a403d4", + "index": 0, + "guid": "98a0c81c-dda3-4ac3-a10e-fb8ed59355c9", + "isActive": false, + "balance": "$3,833.20", + "picture": "http://placehold.it/32x32", + "age": 36, + "eyeColor": "green", + "name": { + "first": "Ramirez", + "last": "Rivera" + }, + "company": "SUPPORTAL", + "email": "ramirez.rivera@supportal.org", + "phone": "+1 (971) 587-2255", + "address": "291 John Street, Hillsboro, Louisiana, 7019", + "about": "Voluptate amet exercitation quis magna. Ullamco aliquip commodo qui proident mollit aliquip anim dolor ut ipsum amet exercitation esse in. Enim dolore consequat laborum officia in ullamco deserunt magna quis. Laboris fugiat ut sunt culpa et incididunt incididunt ad deserunt culpa excepteur consectetur. Dolore amet reprehenderit excepteur voluptate eiusmod deserunt eiusmod consequat eu veniam nisi irure. Minim consectetur esse est voluptate veniam. Eiusmod excepteur incididunt magna officia ut.", + "registered": "Tuesday, August 23, 2016 12:11 AM", + "latitude": "-87.19633", + "longitude": "84.665832", + "tags": [ + "mollit", + "occaecat", + "velit", + "sit", + "dolore" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "George Cochran" + }, + { + "id": 1, + "name": "Blevins Blankenship" + }, + { + "id": 2, + "name": "Marjorie Calhoun" + } + ], + "greeting": "Hello, Ramirez! You have 6 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "5f755f442a60b80114c3ed28", + "index": 1, + "guid": "c06c14b1-b07d-47ed-bddc-9073a93f000f", + "isActive": false, + "balance": "$3,131.39", + "picture": "http://placehold.it/32x32", + "age": 31, + "eyeColor": "green", + "name": { + "first": "Esther", + "last": "Best" + }, + "company": "ISOTRONIC", + "email": "esther.best@isotronic.net", + "phone": "+1 (896) 497-3551", + "address": "765 Meserole Avenue, Sedley, Arkansas, 3426", + "about": "Dolore dolore consectetur occaecat duis eiusmod ut sint dolore irure laboris ea ullamco nulla. Officia voluptate pariatur laboris tempor minim amet culpa deserunt velit nostrud. Velit ex cillum commodo mollit reprehenderit veniam excepteur velit consequat laborum proident qui. Quis cupidatat velit ullamco id eiusmod sint eu dolor eu sint exercitation excepteur adipisicing. Amet voluptate commodo aute incididunt minim velit. Ipsum eiusmod est laboris sit sit in consequat mollit nostrud.", + "registered": "Saturday, October 8, 2016 10:46 PM", + "latitude": "41.287394", + "longitude": "2.328433", + "tags": [ + "commodo", + "sit", + "eu", + "eu", + "velit" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Ginger Wilkerson" + }, + { + "id": 1, + "name": "Hobbs Higgins" + }, + { + "id": 2, + "name": "Brandy Crane" + } + ], + "greeting": "Hello, Esther! You have 6 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5f755f4403adce1c726dc23b", + "index": 2, + "guid": "bc716a2c-5421-42b9-b437-becfe69f11e3", + "isActive": true, + "balance": "$3,151.96", + "picture": "http://placehold.it/32x32", + "age": 34, + "eyeColor": "brown", + "name": { + "first": "Lenora", + "last": "Bennett" + }, + "company": "EXOPLODE", + "email": "lenora.bennett@exoplode.ca", + "phone": "+1 (946) 492-3632", + "address": "709 Lake Street, Jugtown, Nebraska, 610", + "about": "Irure ea consequat duis exercitation incididunt et ad consectetur nulla velit sit aute. Labore ullamco sit commodo non nostrud commodo occaecat mollit minim esse Lorem cupidatat veniam tempor. Reprehenderit Lorem anim enim et ullamco cillum culpa qui ea commodo. Ea incididunt sit tempor enim cillum.", + "registered": "Tuesday, December 30, 2014 11:59 PM", + "latitude": "-43.907388", + "longitude": "97.489236", + "tags": [ + "anim", + "eu", + "Lorem", + "do", + "nisi" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Marcie Crosby" + }, + { + "id": 1, + "name": "Hayes Rowland" + }, + { + "id": 2, + "name": "Lamb Carroll" + } + ], + "greeting": "Hello, Lenora! You have 6 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "5f755f44490b2999bb8aa2a1", + "index": 3, + "guid": "f1e63cb9-0135-4fb5-bc95-9a13ebf332da", + "isActive": true, + "balance": "$1,438.06", + "picture": "http://placehold.it/32x32", + "age": 27, + "eyeColor": "brown", + "name": { + "first": "Mayra", + "last": "Gardner" + }, + "company": "ORBALIX", + "email": "mayra.gardner@orbalix.biz", + "phone": "+1 (931) 581-2234", + "address": "941 Macon Street, Eden, Ohio, 4685", + "about": "Non non labore velit Lorem. Aliquip do adipisicing ullamco aliqua id id. Id aute sit magna nostrud veniam in dolore ullamco.", + "registered": "Friday, April 10, 2020 7:17 PM", + "latitude": "-28.894209", + "longitude": "136.164699", + "tags": [ + "ullamco", + "reprehenderit", + "qui", + "deserunt", + "officia" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Magdalena Boyd" + }, + { + "id": 1, + "name": "Mack Garner" + }, + { + "id": 2, + "name": "Richmond Spencer" + } + ], + "greeting": "Hello, Mayra! You have 5 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "5f755f44596bc18eb81309ed", + "index": 4, + "guid": "922c7d64-fbe2-4867-a758-89fd2a5edeec", + "isActive": false, + "balance": "$3,531.00", + "picture": "http://placehold.it/32x32", + "age": 40, + "eyeColor": "blue", + "name": { + "first": "Bender", + "last": "Joyce" + }, + "company": "XIIX", + "email": "bender.joyce@xiix.tv", + "phone": "+1 (921) 556-2662", + "address": "946 Middleton Street, Tolu, Iowa, 5687", + "about": "Nulla deserunt amet qui eiusmod laboris quis elit est culpa ea fugiat. Nostrud do exercitation voluptate dolor aliquip minim. Veniam sint dolore consectetur ea sunt nulla incididunt excepteur duis eu ea. Reprehenderit ex proident elit est velit occaecat ipsum eu tempor irure commodo magna irure. Amet irure nostrud in non pariatur non cillum commodo et mollit adipisicing. Ullamco proident minim ut irure. Aliqua excepteur pariatur dolor occaecat anim amet.", + "registered": "Thursday, November 27, 2014 9:48 PM", + "latitude": "10.656148", + "longitude": "30.627142", + "tags": [ + "labore", + "dolor", + "nisi", + "fugiat", + "exercitation" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Vinson Brock" + }, + { + "id": 1, + "name": "Buckner Hardin" + }, + { + "id": 2, + "name": "Mccarthy Hanson" + } + ], + "greeting": "Hello, Bender! You have 10 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "5f755f446c0ecc99679f07f0", + "index": 5, + "guid": "93dcef6b-7c60-4c20-8cdf-808cfa3f1145", + "isActive": true, + "balance": "$2,807.58", + "picture": "http://placehold.it/32x32", + "age": 27, + "eyeColor": "brown", + "name": { + "first": "Mcgee", + "last": "Mckee" + }, + "company": "GENMY", + "email": "mcgee.mckee@genmy.io", + "phone": "+1 (854) 501-3539", + "address": "511 Wogan Terrace, Echo, Mississippi, 8205", + "about": "Aliquip laboris ut reprehenderit culpa reprehenderit irure adipisicing consequat eiusmod. Quis pariatur ad voluptate excepteur eu. Non minim pariatur incididunt quis aute minim laborum Lorem laborum ea. Duis consequat velit nisi tempor est qui mollit ullamco. Labore et ut eiusmod in amet reprehenderit aliquip qui sit non irure ullamco consequat anim. Eu in nisi dolor irure duis ex.", + "registered": "Saturday, September 23, 2017 5:39 PM", + "latitude": "-67.317075", + "longitude": "57.365119", + "tags": [ + "sit", + "adipisicing", + "eu", + "consectetur", + "sit" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Francis Stone" + }, + { + "id": 1, + "name": "Stephanie Kim" + }, + { + "id": 2, + "name": "Sherrie Cunningham" + } + ], + "greeting": "Hello, Mcgee! You have 10 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "5f755f44200333e788b95a47", + "index": 6, + "guid": "07c6c403-0a73-4983-8dca-f6cf1caec863", + "isActive": false, + "balance": "$3,097.48", + "picture": "http://placehold.it/32x32", + "age": 25, + "eyeColor": "blue", + "name": { + "first": "Staci", + "last": "Peterson" + }, + "company": "UNI", + "email": "staci.peterson@uni.us", + "phone": "+1 (814) 443-3528", + "address": "640 Brooklyn Road, Cavalero, Rhode Island, 4261", + "about": "Ea non non consequat ipsum magna excepteur ea eu amet ullamco in. Velit sunt id eu esse duis. Id anim ea cillum excepteur. Eu deserunt ex culpa mollit duis officia deserunt ipsum ipsum laborum non ex.", + "registered": "Tuesday, May 19, 2015 12:33 PM", + "latitude": "-73.960556", + "longitude": "176.266376", + "tags": [ + "anim", + "do", + "nulla", + "ut", + "nisi" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Gentry Mcneil" + }, + { + "id": 1, + "name": "Luz Hoover" + }, + { + "id": 2, + "name": "Turner Maldonado" + } + ], + "greeting": "Hello, Staci! You have 8 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5f755f44c9eee03b202a11da", + "index": 7, + "guid": "9d8f63e6-4ba7-490d-83d5-2aa634a3dd4d", + "isActive": false, + "balance": "$3,598.95", + "picture": "http://placehold.it/32x32", + "age": 20, + "eyeColor": "brown", + "name": { + "first": "Cecelia", + "last": "Levine" + }, + "company": "CINCYR", + "email": "cecelia.levine@cincyr.com", + "phone": "+1 (893) 472-3748", + "address": "942 Heath Place, Yogaville, Marshall Islands, 398", + "about": "Minim id voluptate occaecat magna proident. Deserunt sint eiusmod aliqua amet reprehenderit dolore nostrud incididunt esse minim. Eiusmod incididunt ut laboris sunt aute ut sunt mollit minim enim Lorem ex. Dolor nisi occaecat ut labore consequat proident eu sint ut. Culpa ad aliqua consequat officia voluptate dolore et veniam magna eu qui amet. Dolor proident dolore deserunt reprehenderit incididunt culpa sunt dolor sit velit aliqua consectetur eu. Duis commodo quis nulla sunt Lorem mollit reprehenderit et cillum velit cupidatat.", + "registered": "Wednesday, March 9, 2016 10:07 PM", + "latitude": "-75.565217", + "longitude": "-8.072494", + "tags": [ + "cillum", + "minim", + "ad", + "aliqua", + "ut" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Graham Curry" + }, + { + "id": 1, + "name": "Jenifer Mcconnell" + }, + { + "id": 2, + "name": "Farrell Martin" + } + ], + "greeting": "Hello, Cecelia! You have 9 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "5f755f4484cbf6797dfaac85", + "index": 8, + "guid": "4a50bd7b-7c3f-4d58-9f21-f641b520bfab", + "isActive": false, + "balance": "$2,286.92", + "picture": "http://placehold.it/32x32", + "age": 22, + "eyeColor": "blue", + "name": { + "first": "Curry", + "last": "Orr" + }, + "company": "MUSAPHICS", + "email": "curry.orr@musaphics.name", + "phone": "+1 (952) 440-3907", + "address": "423 Furman Street, Darlington, Kentucky, 5418", + "about": "Culpa nostrud dolore do incididunt esse consectetur sunt occaecat aute sint consectetur. Nulla duis dolor nulla elit nostrud ullamco reprehenderit magna cupidatat laboris pariatur. In ex adipisicing excepteur labore aliquip ex reprehenderit officia exercitation consequat voluptate officia. Culpa excepteur nostrud reprehenderit ad eiusmod id nulla cupidatat id et commodo pariatur. Commodo dolore laboris sint in sint. Aliquip nostrud in incididunt id aliqua proident nostrud exercitation exercitation amet consectetur commodo sit.", + "registered": "Tuesday, September 6, 2016 2:33 PM", + "latitude": "-60.915669", + "longitude": "61.059604", + "tags": [ + "aliquip", + "magna", + "voluptate", + "occaecat", + "est" + ], + "range": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "friends": [ + { + "id": 0, + "name": "Fitzgerald Mann" + }, + { + "id": 1, + "name": "Elvia Woods" + }, + { + "id": 2, + "name": "York Mercado" + } + ], + "greeting": "Hello, Curry! You have 10 unread messages.", + "favoriteFruit": "banana" + } + ] \ No newline at end of file