f8a72a0a60658d462753fe39a2119932358ccca5,app/server/views.py,DataUpload,post,#DataUpload#Any#,58
Before Change
import_format = request.POST["format"]
try:
if import_format == "csv":
form_data = TextIOWrapper(
request.FILES["file"].file, encoding="utf-8")
if project.is_type_of(Project.SEQUENCE_LABELING):
Document.objects.bulk_create([
Document(text=line.strip(), project=project)
for line in form_data
])
else:
reader = csv.reader(form_data)
Document.objects.bulk_create([
Document(text=line[0].strip(), project=project)
for line in reader
])
After Change
file = request.FILES["file"].file
documents = []
if import_format == "csv":
documents = self.csv_to_documents(project, file)
elif import_format == "json":
documents = self.json_to_documents(project, file)
// TODO: Move to the configuration
batch_size = 500
while True:
batch = list(it.islice(documents, batch_size))
if not batch:
break
Document.objects.bulk_create(batch, batch_size=batch_size)
return HttpResponseRedirect(reverse("dataset", args=[project.id]))
except DataUpload.ImportFileError as e:
messages.add_message(request, messages.ERROR, e.message)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 11
Instances
Project Name: chakki-works/doccano
Commit Name: f8a72a0a60658d462753fe39a2119932358ccca5
Time: 2018-12-26
Author: sergiy.n@attendify.com
File Name: app/server/views.py
Class Name: DataUpload
Method Name: post
Project Name: okfn-brasil/serenata-de-amor
Commit Name: c50ffb52761973c43aa78e876cd9159fd75f0b56
Time: 2016-09-08
Author: cuducos@gmail.com
File Name: jarbas/core/management/commands/loaddatasets.py
Class Name: Command
Method Name: handle
Project Name: chakki-works/doccano
Commit Name: f8a72a0a60658d462753fe39a2119932358ccca5
Time: 2018-12-26
Author: sergiy.n@attendify.com
File Name: app/server/views.py
Class Name: DataUpload
Method Name: post
Project Name: okfn-brasil/serenata-de-amor
Commit Name: 40e5a6078d978694948f61cc490d9e83c6719088
Time: 2016-09-08
Author: cuducos@gmail.com
File Name: jarbas/core/management/commands/loaddatasets.py
Class Name: Command
Method Name: handle