diff options
| author | typebrook <typebrook@gmail.com> | 2019-11-17 09:18:07 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2019-11-17 09:18:07 +0800 |
| commit | 1d3508f66fddf3f8c6416e59ab9fbde405dbcf25 (patch) | |
| tree | 4f703dfa01596c133a4898c88fe837b8971e47e1 /scripts/csv.move_column | |
| parent | e0673805fc648d47eadf5c76b822ccef5780d241 (diff) | |
update
Diffstat (limited to 'scripts/csv.move_column')
| -rwxr-xr-x | scripts/csv.move_column | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/scripts/csv.move_column b/scripts/csv.move_column deleted file mode 100755 index a62701f..0000000 --- a/scripts/csv.move_column +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | #! /bin/bash | ||
| 2 | |||
| 3 | # show each field with index in csv | ||
| 4 | echo -------------- > /dev/tty | ||
| 5 | head -1 < $1 | sed 's/,/ /g' | awk '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' > /dev/tty | ||
| 6 | echo -------------- > /dev/tty | ||
| 7 | echo > /dev/tty | ||
| 8 | |||
| 9 | # get index of lon/lat column | ||
| 10 | read -p "Move which column? " origin_col | ||
| 11 | read -p "To which index? " new_col | ||
| 12 | |||
| 13 | cat $1 | | ||
| 14 | # move lon and lat to the first and second column | ||
| 15 | awk -F',' -v OFS="," -v origin_th=$origin_col -v new_th=$new_col '\ | ||
| 16 | {for (i=1; i<= NF; i++) if (i == new_th) printf $origin_th OFS $i OFS; else if (i == origin_th); else printf $i OFS; print ""}\ | ||
| 17 | ' |\ | ||
| 18 | sed 's/,$//g' | ||