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
I was messing around with this for a project, we ended up not using it but it might be handy in an addon:
from prom import Orm, Schema, Field import os import re class CSVOrm(Orm): _id = _created = _updated = pk = None @classmethod def create_schema(cls, csvpath): c = CSV(csvpath) fields = {} table_name = os.path.splitext(os.path.basename(csvpath))[0] for row in c: for k, v in row.items(): if k not in fields: fields[k] = Field(str, name=k) #fields = {k: Field(str) for k in row.keys()} if v: if v.lower() in set(["true", "false", "t", "f", "1", "0", "y", "n"]): if fields[k]._type is str: fields[k]._type = bool elif v.isdigit(): fields[k]._type = int elif re.match("^\d+\.\d+$", v): fields[k]._type = float else: fields[k]._type = str else: fields[k].required = False return Schema(table_name, **fields)
It builds upon #95
The CSV class is a small wrapper around the csv.DictReader module that can read utf-8 csv files, so it would be easily to switch that code out.
CSV
csv.DictReader
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I was messing around with this for a project, we ended up not using it but it might be handy in an addon:
It builds upon #95
The
CSV
class is a small wrapper around thecsv.DictReader
module that can read utf-8 csv files, so it would be easily to switch that code out.The text was updated successfully, but these errors were encountered: