We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From an operational perspective it would be nice to read and write schemas.
import json import polars as pl custom_schema = pl.Schema({'Employee ID':pl.Int64 ,'First Name':pl.String ,'Last Name':pl.String ,'Gender':pl.String ,'Date of Birth':pl.Date ,'Department':pl.String ,'Position':pl.String ,'Salary ($)':pl.Float64 ,'Email':pl.String ,'Phone':pl.String}) def write_schema(fp): string_values = [str(value) for value in custom_schema.dtypes()] schema_dict = dict(zip(custom_schema.names(),string_values)) f = open(fp,'w') f.write(json.dumps(schema_dict)) f.close() fp = 'employees_schema.json' write_schema(fp)
import json fp = 'employees_schema.json' def read_schema(fp): f = open(fp,'r') schema = json.load(f) f.close() names = list(schema.keys()) data_types = [] for key, value in schema.items(): if value == 'Int64': value = pl.Int64 data_types.append(value) if value == 'String': value = pl.String data_types.append(value) if value == 'Date': value = pl.Date data_types.append(value) else: pass schema_dict = dict(zip(names,data_types)) schema_object = pl.Schema(schema_dict) return schema_object schema = read_schema(fp) schema
@ritchie46
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
From an operational perspective it would be nice to read and write schemas.
Use Cases:
Example solution for exporting schema
Example solution for importing schemas
@ritchie46
The text was updated successfully, but these errors were encountered: