f8a72a0a60658d462753fe39a2119932358ccca5,app/server/views.py,DataUpload,post,#DataUpload#Any#,58

Before Change


                    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)

After Change


        import_format = request.POST["format"]
        try:
            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)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

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: UFAL-DSG/tgen
Commit Name: 0e042f5e025f04b74e77bd3971adbb290e1bf5fd
Time: 2016-04-26
Author: odusek@ufal.mff.cuni.cz
File Name: run_tgen.py
Class Name:
Method Name: seq2seq_gen


Project Name: estnltk/estnltk
Commit Name: 8965b34d036e7f81047d6ee9a1808e3140db9236
Time: 2016-11-11
Author: alex.tk.fb@gmail.com
File Name: estnltk/ner.py
Class Name:
Method Name: json_document_to_estner_document