Commit f1bfdfcc authored by Marco Govoni's avatar Marco Govoni
Browse files

Added Yaml 2 Json converter

parent e0f8dcc3
......@@ -10,6 +10,7 @@ The software is tested for python version 3.x and has the following dependencies
- ``numpy``
- ``scipy``
- ``matplotlib``
- ``pyyaml``
- ``datetime``
- ``requests``
- ``mendeleev``
......
......@@ -12,6 +12,7 @@ setup(name='westpy',
'numpy',
'scipy',
'matplotlib',
'pyyaml',
'datetime',
'requests',
'mendeleev',
......
......@@ -126,6 +126,27 @@ def readJsonFile(fname):
print("File read : ", fname )
return data
def convertYaml2Json(fyml,fjson):
"""Converts the file from YAML to JSON.
:param fyml: Name of YAML file
:type fyml: string
:param fjson: Name of JSON file
:type fjson: string
:Example:
>>> from westpy import *
>>> convertYaml2Json("file.yml","file.json")
.. note:: The file fjon will be created, fyml will not be overwritten.
"""
#
import yaml, json
from westpy import writeJsonFile
#
data = yaml.load(open(fyml))
writeJsonFile(fjson,data)
def listLinesWithKeyfromOnlineText(url,key):
"""List lines from text file located at url, with key.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment