<?xml version="1.0" encoding="UTF-8"?>
<text>
<line1>Hello World!</line1>
<line2>Hello World!</line2>
</text>
# Python code to read XML
import xml.etree.ElementTree as xml
tree = xml.parse('test.xml')
myxml = tree.getroot()
JSON (JavaScript Object Notation)
JSON is lightweight, easy to read, and widely used in REST APIs. It consists of key-value pairs and supports nested objects and arrays.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
Elevate Your IT Efficiency with Expert Solutions
Transform Your Technology, Propel Your Business
Unlock advanced technology solutions tailored to your business needs. At InventiveHQ, we combine industry expertise with innovative practices to enhance your cybersecurity, streamline your IT operations, and leverage cloud technologies for optimal efficiency and growth.
[{
"Name" : "Bob",
"City" : "San Diego",
"State" : "CA"
},
{
"Name" : "Sue",
"City" : "San Francisco",
"State" : "CA"
}]
# Python code to work with JSON
import json
data = json.loads(json_string)
print(json.dumps(data, indent=2))
Advantage: JSON is less verbose than XML, taking less storage space and bandwidth, which translates to faster web applications.
CSV (Comma Separated Values)
CSV files have a row of headings followed by data rows, with each column separated by commas. They’re commonly used for database exports and spreadsheet data.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
Elevate Your IT Efficiency with Expert Solutions
Transform Your Technology, Propel Your Business
Unlock advanced technology solutions tailored to your business needs. At InventiveHQ, we combine industry expertise with innovative practices to enhance your cybersecurity, streamline your IT operations, and leverage cloud technologies for optimal efficiency and growth.
Name, City, State
bob,San Diego,CA
sue,New York,NY
joe,Miami,FL
# Python code to read CSV
import csv
with open('data.csv', 'r') as file:
csv_reader = csv.reader(file)
for row in csv_reader:
print(row)
YAML (YAML Ain’t Markup Language)
YAML is commonly used for configuration files and is similar to JSON but uses indentation instead of brackets. It’s space-sensitive like Python.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
Elevate Your IT Efficiency with Expert Solutions
Transform Your Technology, Propel Your Business
Unlock advanced technology solutions tailored to your business needs. At InventiveHQ, we combine industry expertise with innovative practices to enhance your cybersecurity, streamline your IT operations, and leverage cloud technologies for optimal efficiency and growth.
---
Bob:
City: San Diego
State: CA
Sue:
City: New York
State: NY
# Python code to work with YAML
import yaml
with open('data.yml', 'r') as file:
data = yaml.safe_load(file)
print(yaml.dump(data))
Databases
Databases are specialized programs for storing, organizing, and retrieving data at scale. They provide programmatic interfaces and handle data consistency automatically.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
Elevate Your IT Efficiency with Expert Solutions
Transform Your Technology, Propel Your Business
Unlock advanced technology solutions tailored to your business needs. At InventiveHQ, we combine industry expertise with innovative practices to enhance your cybersecurity, streamline your IT operations, and leverage cloud technologies for optimal efficiency and growth.
Frequently Asked Questions
Find answers to common questions
Related Articles

Building REST APIs with Flask: Complete Python Guide
Learn to build dynamic web applications with Python and Flask – from installation to deployment with step-by-step tutorials

Building a Classifier Using Python and Scikit-Learn

Convert JSON to CSV in Python: Complete Tutorial
When working with data in Python, you’ll frequently encounter situations where you need to convert between JSON and CSV formats. Whether you’re processing API responses, preparing data for analysis, o...
Automate Your IT Operations
Leverage automation to improve efficiency, reduce errors, and free up your team for strategic work.