Merge branch 'main' into prototyp-2-fabio
This commit is contained in:
34
src/lib/csv-parser.ts
Normal file
34
src/lib/csv-parser.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* CSV parser that handles quoted fields
|
||||
*/
|
||||
export function parseCSVLine(line: string): string[] {
|
||||
const values: string[] = [];
|
||||
let current = '';
|
||||
let inQuotes = false;
|
||||
|
||||
for (let i = 0; i < line.length; i++) {
|
||||
const char = line[i];
|
||||
const nextChar = line[i + 1];
|
||||
|
||||
if (char === '"') {
|
||||
if (inQuotes && nextChar === '"') {
|
||||
// Escaped quote
|
||||
current += '"';
|
||||
i++;
|
||||
} else {
|
||||
// Toggle quote state
|
||||
inQuotes = !inQuotes;
|
||||
}
|
||||
} else if (char === ',' && !inQuotes) {
|
||||
// Field separator
|
||||
values.push(current.trim());
|
||||
current = '';
|
||||
} else {
|
||||
current += char;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the last field
|
||||
values.push(current.trim());
|
||||
return values;
|
||||
}
|
||||
@@ -16,6 +16,10 @@ export const dataset_entry = sqliteTable('dataset_entry', {
|
||||
dialect: text('dialect').notNull(),
|
||||
iteration: integer('iteration').notNull(),
|
||||
durationMs: integer('duration_ms'),
|
||||
rmsValue: real('rms_value'),
|
||||
longestPause: real('longest_pause'),
|
||||
utmosScore: real('utmos_score'),
|
||||
werScore: real('wer_score'),
|
||||
createdAt: integer('created_at', { mode: 'timestamp' })
|
||||
.notNull()
|
||||
.default(sql`(unixepoch())`),
|
||||
|
||||
Reference in New Issue
Block a user