Skip to content
Advertisement

Python- Generate schema from file using TableSchema

I am trying to generate a schema from a csv file using TableSchame package.

def main():
        cls = '/Users//Downloads/s3_03b8a5f1-eddc-4ac5-9d72-.csv'
        with open(cls, "rb") as f:
             df= csv.reader(f)

        table= Table(df)
        table.infer(limit=500, confidence=0.55)

Gives me “raise exceptions.SourceError(message) tabulator.exceptions.SourceError: Only callable returning an iterator is supported”

How do i get the Table to work with a csv file?

Advertisement

Answer

Table can be used by directly passing the CSV file path, see the docs:

table= Table(cls)
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement