mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
628 B
32 lines
628 B
3 years ago
|
import Papaparse from 'papaparse'
|
||
3 years ago
|
import TemplateGenerator from '~/components/import/templateParsers/TemplateGenerator'
|
||
3 years ago
|
export default class CSVTemplateAdapter extends TemplateGenerator {
|
||
|
constructor(name, data) {
|
||
|
super()
|
||
|
this.name = name
|
||
3 years ago
|
this.csvData = data
|
||
3 years ago
|
this.project = {
|
||
|
title: this.name,
|
||
|
tables: []
|
||
|
}
|
||
|
this.data = {}
|
||
|
}
|
||
|
|
||
3 years ago
|
async init() {
|
||
|
this.csv = Papaparse.parse(this.csvData, { header: true })
|
||
|
}
|
||
|
|
||
3 years ago
|
parseData() {
|
||
|
this.columns = this.csv.meta.fields
|
||
|
this.data = this.csv.data
|
||
|
}
|
||
|
|
||
|
getColumns() {
|
||
|
return this.columns
|
||
|
}
|
||
|
|
||
|
getData() {
|
||
|
return this.data
|
||
|
}
|
||
|
}
|