Parsing Files in Python

Parsing Files in Python

Day 15 of 90daysofdevops

·

2 min read

Hello Readers,

Here we are Day 15 of #90daysofdevops

👣 Topics for #day15

  • JSON

  • YAML

  • Python Libraries

  • Tasks of Day15


JSON

JSON stands for JavaScript Object Notation.

It is a lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate.

JSON is a text format that is completely language-independent, meaning that it can be used to represent data structures in any programming language.

JSON data is represented as key-value pairs, with the keys being strings and the values being of various types, including strings, numbers, arrays, and objects.

Example:

{
    "name": "Manu",
    "age": 75,
    "city": "Antartica"
}

In this example, we have an object with three key-value pairs.

The keys are "name", "age", and "city", and the corresponding values are "Manu", 75, and "Antartica".


YAML

YAML (short for "YAML Ain't Markup Language") is a human-readable data serialization format.

It is often used for configuration files, but can also be used for data exchange between languages and platforms.

YAML is designed to be easy to read and write, with a syntax that is more concise and readable than other markup languages like XML or JSON.

YAML is whitespace-sensitive, meaning that indentation is used to indicate structure and hierarchy within the data.

Example:

name: Madhu
age: 25
address:
  street: ondane adda gode
  city: namde town
  state: namde state
  zip code: 999999

In this example, we have a YAML file representing a person's name, age, and address. The file consists of a series of key-value pairs, where the keys are strings and the values can be any valid data type, including strings, numbers, booleans, arrays, and objects. Note that the indentation is used to indicate the structure of the data - the "address" key contains a sub-object with its own key-value pairs, indented one level deeper than the parent object.


Python Libraries

Python has a rich ecosystem of libraries and modules that are commonly used by DevOps engineers in their day-to-day tasks.

Here are few:

  1. os

  2. sys

  3. json

  4. yaml

  5. logging

  6. argparse

  7. requests


Tasks of Day 15

Solution:

  1. .

  1. .


Thank you for reading my Blog. I hope you have learnt something from it! If you find this blog helpful, please like, share, and follow me for more interesting posts like this in the future.

Pavan Kumar R

Please navigate to my GitHub Repo: GitHub Repo Link

to check my solutions for the tasks of 90daysofdevops Challenge.

LinkedIn Link

Â