Add new task skeleton

This commit is contained in:
2025-10-08 11:54:45 +02:00
parent cdf659ec4a
commit ad90a4ed58
10 changed files with 289 additions and 0 deletions

30
task_2_ts/ts/csv.ts Normal file
View File

@@ -0,0 +1,30 @@
import {
csv2json
} from 'json-2-csv';
export type CSV_Data = Array<Record<string, unknown>>;
const convertCSVtoJSON = async ( csvText: string ) => {
// Type cast OK, as the typing of the external library is not perfect.
return ( await csv2json( csvText ) ) as CSV_Data;
};
/**
* Reads a CSV file and returns the data as JSON.
* @param event The change event of the file input.
*/
export const readCSV = async ( event: Event ): Promise<CSV_Data> => {
if ( !( event.target instanceof HTMLInputElement ) ) {
throw new Error( 'Not an HTMLInputElement' );
}
const file = event.target.files?.[0];
if ( file == null ) {
throw new Error( 'No file selected' );
}
const result = await file.text();
return await convertCSVtoJSON( result );
};

5
task_2_ts/ts/main.ts Normal file
View File

@@ -0,0 +1,5 @@
import "@fortawesome/fontawesome-free/css/all.css";
import "../css/layout.css";
import "@picocss/pico/css/pico.min.css";
// TODO start here with the first entry point