Skip to content
Snippets Groups Projects
Commit 34cfaa3c authored by Timothee P's avatar Timothee P :sunflower:
Browse files

remove duplicated array useless

parent 3fb2e718
No related branches found
No related tags found
No related merge requests found
...@@ -633,10 +633,9 @@ export default { ...@@ -633,10 +633,9 @@ export default {
try { try {
fr.readAsText(this.csvFileToImport); fr.readAsText(this.csvFileToImport);
fr.onloadend = () => { fr.onloadend = () => {
let content = fr.result;
// Find csv delimiter // Find csv delimiter
const commaDelimited = content.split('\n')[0].includes(','); const commaDelimited = fr.result.split('\n')[0].includes(',');
const semicolonDelimited = content.split('\n')[0].includes(';'); const semicolonDelimited = fr.result.split('\n')[0].includes(';');
const delimiter = commaDelimited && !semicolonDelimited ? ',' : semicolonDelimited ? ';' : false; const delimiter = commaDelimited && !semicolonDelimited ? ',' : semicolonDelimited ? ';' : false;
if ((commaDelimited && semicolonDelimited) || !delimiter) { if ((commaDelimited && semicolonDelimited) || !delimiter) {
...@@ -645,7 +644,7 @@ export default { ...@@ -645,7 +644,7 @@ export default {
return; return;
} }
// Check if file contains 'lat' and 'long' fields // Check if file contains 'lat' and 'long' fields
const headers = content const headers = fr.result
.split('\n')[0] .split('\n')[0]
.split(delimiter) .split(delimiter)
.map(el => { .map(el => {
...@@ -657,7 +656,7 @@ export default { ...@@ -657,7 +656,7 @@ export default {
// Look for 2 decimal fields in first line of csv // Look for 2 decimal fields in first line of csv
// corresponding to lon and lat // corresponding to lon and lat
const sampleLine = const sampleLine =
content fr.result
.split('\n')[1] .split('\n')[1]
.split(delimiter) .split(delimiter)
.map(el => { .map(el => {
...@@ -666,7 +665,7 @@ export default { ...@@ -666,7 +665,7 @@ export default {
.filter(Boolean); .filter(Boolean);
if (sampleLine.length > 1 && headersCoord.length === 2) { if (sampleLine.length > 1 && headersCoord.length === 2) {
this.csvError = null; this.csvError = null;
this.csvImport = csvToJson(content, delimiter); this.csvImport = csvToJson(fr.result, delimiter);
this.featureTypeImporting = false; this.featureTypeImporting = false;
//* stock filename to import features afterward //* stock filename to import features afterward
this.SET_FILE_TO_IMPORT(this.csvFileToImport); this.SET_FILE_TO_IMPORT(this.csvFileToImport);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment