Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for importing tsv files #181

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions graphql-server/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ enum ImportOperation {
enum FileType {
Csv
Psv
Tsv
}

"""The `Upload` scalar type represents a file upload."""
Expand Down
1 change: 1 addition & 0 deletions graphql-server/src/tables/table.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ registerEnumType(ImportOperation, { name: "ImportOperation" });
export enum FileType {
Csv,
Psv,
Tsv,
// Xlsx,
// Json,
// Sql,
Expand Down
3 changes: 3 additions & 0 deletions graphql-server/src/tables/upload.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,8 @@ function getDelim(ft: FileType): string {
if (ft === FileType.Psv) {
return "|";
}
if (ft === FileType.Tsv) {
return "\t";
}
return ",";
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const oneMB = 1024 * 1024;
const numMB = 400;
const maxFileSize = numMB * oneMB; // ~ 150MB

export const validTypes = ["csv", "psv"];
export const validTypes = ["csv", "psv", "tsv"];

type ReturnType = {
dragOver: (e: DragEvent<HTMLDivElement>) => void;
Expand Down Expand Up @@ -119,6 +119,8 @@ function toFileType(extension: string): FileType {
return FileType.Csv;
case "psv":
return FileType.Psv;
case "tsv":
return FileType.Tsv;
default:
throw new Error("invalid file type");
}
Expand Down
3 changes: 2 additions & 1 deletion web/gen/graphql-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export type DoltWriter = {

export enum FileType {
Csv = 'Csv',
Psv = 'Psv'
Psv = 'Psv',
Tsv = 'Tsv'
}

export type ForeignKey = {
Expand Down
Loading