Skip to content

Commit

Permalink
fix colc cannot analyse tsv
Browse files Browse the repository at this point in the history
  • Loading branch information
solaoi committed Mar 26, 2022
1 parent ad9c754 commit d627374
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ you can download a binary release
```sh
# Install with wget or curl
## set the latest version on releases.
VERSION=v1.0.7
VERSION=v1.0.8
## case you use wget
wget https://github.com/solaoi/colc/releases/download/$VERSION/colc_linux_amd64.tar.gz
## case you use curl
Expand Down
14 changes: 9 additions & 5 deletions colc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ const binSize: number | null = (() => {

const isCsv = filename.endsWith(".csv");
const headerName = await runner.run(
`head -n 1 ${filename}| cut -f${column} ${isCsv && "-d, "}| tr -d 0-9.-`,
`head -n 1 ${filename}| cut -f${column} ${isCsv ? "-d, " : ""}| tr -d 0-9.-`,
);
const hasHeader = headerName !== "";

if (binSize === null) {
const statsCommand = (() => {
const bash = [];
if (hasHeader) {
bash.push(`tail -n +2 ${filename} | cut -f${column} ${isCsv && "-d, "}`);
bash.push(
`tail -n +2 ${filename} | cut -f${column} ${isCsv ? "-d, " : ""}`,
);
} else {
bash.push(
`cut -f${column} ${isCsv && "-d, "}${filename} `,
`cut -f${column} ${isCsv ? "-d, " : ""}${filename} `,
);
}
bash.push("| sort -n | awk");
Expand Down Expand Up @@ -78,10 +80,12 @@ if (binSize === null) {
const freqCommand = (() => {
const bash = [];
if (hasHeader) {
bash.push(`tail -n +2 ${filename} | cut -f${column} ${isCsv && "-d, "}`);
bash.push(
`tail -n +2 ${filename} | cut -f${column} ${isCsv ? "-d, " : ""}`,
);
} else {
bash.push(
`cut -f${column} ${isCsv && "-d, "}${filename} `,
`cut -f${column} ${isCsv ? "-d, " : ""}${filename} `,
);
}
bash.push("| awk");
Expand Down

0 comments on commit d627374

Please sign in to comment.