I have a large number of columns that should be populated with a CSV file. I have the following is the code to read from the csv file (load_csv.py) I get an error in loading load_csv.py I have read because it is using the default You want to apply the dictionary as a keyword argument: or your __ init __ code inside the definition of the model
class table column 1 = ............ column 2 = ............. ....... def __init__ (Self, ** kwargs): self .__ dict __. Update (kwargs)
in the csv_file line for data_file = "data.csv" Csv_file = csv.DictReader (open (data_file, 'ru'), delimiter = ','): table_entries = {} in row, value in row.items (): table_entries [key] = value table_row = table_entries Db.session.add (table_row) db.session.commit ()
table_row = table ( Table_entries) TypeError: __init __ () takes exactly 1 argument (2 given)
__ init__ But I can not see how this code is defined in the
__init __ function I. Any help in solving this problem would be greatly appreciated.
< Code> table_row = To get a table, replace the table (** table_entries)
table () class:
< Code> class table def __int __ (self, line): auto_dial dial__. Update (line)
No comments:
Post a Comment