Browse Source

[importer] polishing importer direct upload

ayush.goyal 4 years ago
parent
commit
318cbfc0fd

+ 4 - 4
desktop/libs/indexer/src/indexer/api3.py

@@ -246,15 +246,15 @@ def guess_field_types(request):
         csv_data.append(row)
         csv_data.append(row)
 
 
     field_type_guesses = []
     field_type_guesses = []
-    for col in range(len(column_row)):
-      column_samples = [sample_row[col] for sample_row in sample if len(sample_row) > col]
+    for count, col in enumerate(column_row):
+      column_samples = [sample_row[count] for sample_row in sample if len(sample_row) > count]
 
 
       field_type_guess = guess_field_type_from_samples(column_samples)
       field_type_guess = guess_field_type_from_samples(column_samples)
       field_type_guesses.append(field_type_guess)
       field_type_guesses.append(field_type_guess)
 
 
     columns = [
     columns = [
-      Field(column_row[i], field_type_guesses[i]).to_dict()
-      for i in range(len(column_row))
+      Field(column_row[count], field_type_guesses[count]).to_dict()
+      for count, col in enumerate(column_row)
     ]
     ]
 
 
     format_ = {
     format_ = {

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -3185,7 +3185,7 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
           var files = $('#inputfile')[0].files[0];
           var files = $('#inputfile')[0].files[0];
           fd.append('inputfile', files);
           fd.append('inputfile', files);
           fd.append('fileFormat', ko.mapping.toJSON(viewModel.createWizard.source));
           fd.append('fileFormat', ko.mapping.toJSON(viewModel.createWizard.source));
-  
+          ## $.post ??
           $.ajax({
           $.ajax({
               url: '/indexer/api/indexer/guess_field_types',
               url: '/indexer/api/indexer/guess_field_types',
               type: 'post',
               type: 'post',