An universal parser for various file formats
Project description
universal-parser
An universal parser for various file formats.
usage
This package can be used to parse and validate data from various file formats like JSON, XML, CSV, YAML.
install univeral-parser package
pip install -r universal-parser-it-stud-io
create app.py file
json_data = '{"name": "John", "age": 30}'
json_schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"}
},
"required": ["name", "age"]
}
xml_data = '<person><name>John</name><age>30</age></person>'
xml_schema = '''
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
'''
csv_data = 'name,age\nJohn,30'
csv_schema = {
"name": str,
"age": int
}
yaml_data = '''
name: John
age: 30
'''
yaml_schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"}
},
"required": ["name", "age"]
}
from universal_parser_it_stud_io import UniversalParser
parser = UniversalParser.UniversalParser(json_data)
print("Detected format: ", parser.get_detected_format())
print(parser.parse())
print(parser.validate(json_schema))
parser = UniversalParser.UniversalParser(xml_data)
print("Detected format: ", parser.get_detected_format())
print(parser.parse())
print(parser.validate(xml_schema))
parser = UniversalParser.UniversalParser(csv_data)
print("Detected format: ", parser.get_detected_format())
print(parser.parse())
print(parser.validate(csv_schema))
parser = UniversalParser.UniversalParser(yaml_data)
print("Detected format: ", parser.get_detected_format())
print(parser.parse())
print(parser.validate(yaml_schema))
run app.py
python app.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file universal_parser_it_stud_io-1.0.1.tar.gz.
File metadata
- Download URL: universal_parser_it_stud_io-1.0.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04b601b0026430528d25ae68645733f30b48ce123c08d4035c44aa71b274675d
|
|
| MD5 |
69f827e10053556adbd351aa0420bfd4
|
|
| BLAKE2b-256 |
28f3cb4041d4e4ae70f63a2f0b2cefe02882187402560f716038fbd4de17964a
|
File details
Details for the file universal_parser_it_stud_io-1.0.1-py3-none-any.whl.
File metadata
- Download URL: universal_parser_it_stud_io-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32e97d76e9c297b04fe459ae144d0b4555d8065f5316274c0bd13594e88079d8
|
|
| MD5 |
37ef42011667d172f26ef503697e2fcf
|
|
| BLAKE2b-256 |
4a1632283b110f51cc12d24aec3b12cf30fbebf1872c76feb5ff9ebafc9bc342
|