Say I have a dataframe that has a row like:
{'ID':'123245','Comment':'This is my longer comment','Tax':1.07,'Units':2.0}
Is there a way in Python to do something like:
max([len(str(i)) for i in set(df['Comments'])])
And infer the max varchar and other metadata that I could then construct a SQL query to create that table (in my case, for SnowFlake)?
Since it would take additional logic not mentioned (e.g. try to cast as int, float, datetime, etc.), perhaps this is commonly done in an existing library.
Right now, it takes me some time for each endpoint to manually check across the fields and infer how to make each table in Snowflake, again, manually. Would like to automate this process.
Of course, one aspect of automating this without something more sophisticated like a library is that your max fields now (such as a comment that's 199 characters long) will likely be soon violated by future inputs into those fields if not, say, rounded up to a 'max' varchar such as telling such an algorithm a minimum varchar when it can't convert to float/int/date/etc.