setattr(self, cell_key.rstrip(‘_filepath’), [sf.File.upload(filepath, app) for filepath in cell_val.split(‘;’)])
AttributeError: ‘NoneType’ object has no attribute ‘split’
Traceback (most recent call last):
File “C:\Users\XXXX\Desktop\新しいフォルダー\post.py”, line 19, in <module>
records = [Record(app, row) for row in data]
File “C:\Users\XXXX\Desktop\新しいフォルダー\post.py”, line 19, in <listcomp>
records = [Record(app, row) for row in data]
File “C:\Users\XXXX\Desktop\新しいフォルダー\post.py”, line 12, in __init__
setattr(self, cell_key.rstrip(‘_filepath’), [sf.File.upload(filepath, app) for filepath in cell_val.split(‘;’)])
AttributeError: ‘NoneType’ object has no attribute ‘split’
import pykintone
from pykintone import model
import pykintone.structure_field as sf
import codecs
import csv
class Record(model.kintoneModel):
def __init__ (self, app, row):
super(Record, self). __init__ ()
for cell_key, cell_val in row.items():
if '_filepath' in cell_key:
setattr(self, cell_key.rstrip('_filepath'), [sf.File.upload(filepath, app) for filepath in cell_val.split(';')])
else:
setattr(self, cell_key, cell_val)
app = pykintone.load('account.yml').app()
with codecs.open('data.csv', 'r', 'utf-8') as csvfile:
data = csv.DictReader(csvfile)
for index, row in enumerate(data):
for cell_key, cell_val in row.items():
print(cell_key + '[' + str(index) + ']: ' + cell_val)
# records = [Record(app, row) for row in data]
# for i in range(0, len(records), 100):
# app.batch_create(records[i:i+100])
C:\Users\XXXX\AppData\Local\Programs\Python\Python38\lib\site-packages\pykintone\account.py:48: YAMLLoadWarning: calling yaml.load() without Loader=… is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
a_dict = yaml.load(f)
import pykintone
from pykintone import model
import pykintone.structure_field as sf
import codecs
import csv
import mimetypes
class Record(model.kintoneModel):
def __init__ (self, app, row):
super(Record, self). __init__ ()
for cell_key, cell_val in row.items():
if '_filepath' in cell_key:
setattr(self, cell_key.rstrip('_filepath'), [sf.File.upload(filepath, app, '', mimetypes.guess_type(filepath)) for filepath in cell_val.split(';')])
else:
setattr(self, cell_key, cell_val)
app = pykintone.load('account.yml').app()
with codecs.open('data.csv', 'r', 'utf-8') as csvfile:
data = csv.DictReader(csvfile)
records = [Record(app, row) for row in data]
for i in range(0, len(records), 100):
app.batch_create(records[i:i+100])