diff --git a/src/app/services/parse-file.service.spec.ts b/src/app/services/parse-file.service.spec.ts index 6f7129c..af54764 100644 --- a/src/app/services/parse-file.service.spec.ts +++ b/src/app/services/parse-file.service.spec.ts @@ -1,4 +1,5 @@ import { Result } from "ts-results" + import { KLineSource } from "../shared/types" import { ParseFileService } from "./parse-file.service" @@ -111,8 +112,6 @@ describe("ParseFileService", () => { expect(service.json(_2).val).toEqual(_2_e) }) - test("raw()", () => {}) - test("extractKLineFromParsed()", () => { const _1 = [ ["1696497780000", "27687.9", "27718.5", "27687.9", "27698.5", "1041.273"], diff --git a/src/app/services/parse-file.service.ts b/src/app/services/parse-file.service.ts index ee2f52f..2c0e608 100644 --- a/src/app/services/parse-file.service.ts +++ b/src/app/services/parse-file.service.ts @@ -24,7 +24,7 @@ export class ParseFileService { // csv, tsv, txt: As is (TOHLCV is assumed to be in order) if (file.ext !== "json") { - if (!/^[0-9,\s\[\]]+$/.test(file.value)) { + if (!/^[0-9,\.\s\[\]]+$/.test(file.value)) { return new Err(new ParseError(`${file.name}.${file.ext}`)) } } @@ -143,7 +143,7 @@ export class ParseFileService { } protected raw(value: string): Result { - const parsed = Papa.parse(value, { delimiter: "," }) + const parsed = Papa.parse(value) if (0 < parsed.errors.length) { return new Err(Error()) } @@ -163,6 +163,8 @@ export class ParseFileService { ) } else if (value.includes(",")) { result = parsed.data as Array> + } else if (value.includes("\t")) { + result = parsed.data as Array> } else { return new Err(Error()) }