Can I change a text file into a spreadsheet with grid lines, using a bash script?

Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I have the information below and I want it to look like it is in a spreadsheet with a header.
cat TEXT-FILE.txt
SOMETHING5 : 11111111 : 1969-08-12 : 42.34
SOMETHING4 : 22222222 : 1969-08-12 : 700.12
SOMETHING3 : 333333333 : 1969-08-12 : 300.2
SOMETHING2 : 44444444444 : 1969-08-12 : 200.2
SOMETHING1 : 5555555555 : 1969-08-12 : 100.34
This is as far as I've gotten with my script
#!/bin/bash
for file in ./TEST-FILE.txt
do
sed -i -e "s/:/|/g" $file
sed -i '1iIdentify | Misc | Date | Amount | Confirmation ' $file
done
The output is now:
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
I'm unsure how to make the lines match up, also the Confirmation column is blank as this will eventually be manually entered info.
Long story Long - I wanted this output to look like a proper spreadsheet, including grid lines. No other questions I've found exactly answer what I'm trying to do.
linux bash
add a comment |Â
up vote
3
down vote
favorite
I have the information below and I want it to look like it is in a spreadsheet with a header.
cat TEXT-FILE.txt
SOMETHING5 : 11111111 : 1969-08-12 : 42.34
SOMETHING4 : 22222222 : 1969-08-12 : 700.12
SOMETHING3 : 333333333 : 1969-08-12 : 300.2
SOMETHING2 : 44444444444 : 1969-08-12 : 200.2
SOMETHING1 : 5555555555 : 1969-08-12 : 100.34
This is as far as I've gotten with my script
#!/bin/bash
for file in ./TEST-FILE.txt
do
sed -i -e "s/:/|/g" $file
sed -i '1iIdentify | Misc | Date | Amount | Confirmation ' $file
done
The output is now:
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
I'm unsure how to make the lines match up, also the Confirmation column is blank as this will eventually be manually entered info.
Long story Long - I wanted this output to look like a proper spreadsheet, including grid lines. No other questions I've found exactly answer what I'm trying to do.
linux bash
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have the information below and I want it to look like it is in a spreadsheet with a header.
cat TEXT-FILE.txt
SOMETHING5 : 11111111 : 1969-08-12 : 42.34
SOMETHING4 : 22222222 : 1969-08-12 : 700.12
SOMETHING3 : 333333333 : 1969-08-12 : 300.2
SOMETHING2 : 44444444444 : 1969-08-12 : 200.2
SOMETHING1 : 5555555555 : 1969-08-12 : 100.34
This is as far as I've gotten with my script
#!/bin/bash
for file in ./TEST-FILE.txt
do
sed -i -e "s/:/|/g" $file
sed -i '1iIdentify | Misc | Date | Amount | Confirmation ' $file
done
The output is now:
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
I'm unsure how to make the lines match up, also the Confirmation column is blank as this will eventually be manually entered info.
Long story Long - I wanted this output to look like a proper spreadsheet, including grid lines. No other questions I've found exactly answer what I'm trying to do.
linux bash
I have the information below and I want it to look like it is in a spreadsheet with a header.
cat TEXT-FILE.txt
SOMETHING5 : 11111111 : 1969-08-12 : 42.34
SOMETHING4 : 22222222 : 1969-08-12 : 700.12
SOMETHING3 : 333333333 : 1969-08-12 : 300.2
SOMETHING2 : 44444444444 : 1969-08-12 : 200.2
SOMETHING1 : 5555555555 : 1969-08-12 : 100.34
This is as far as I've gotten with my script
#!/bin/bash
for file in ./TEST-FILE.txt
do
sed -i -e "s/:/|/g" $file
sed -i '1iIdentify | Misc | Date | Amount | Confirmation ' $file
done
The output is now:
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
I'm unsure how to make the lines match up, also the Confirmation column is blank as this will eventually be manually entered info.
Long story Long - I wanted this output to look like a proper spreadsheet, including grid lines. No other questions I've found exactly answer what I'm trying to do.
linux bash
linux bash
edited Aug 10 at 16:33
Jesse_b
10.5k22659
10.5k22659
asked Aug 10 at 16:05
Emile
989
989
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
I'm unsure how to make the lines match up
Have a look at column.
Original file
$ cat columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
With column
$ column -t columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
As you can see from above, using column makes the output align nicely, and the blank Confirmation column is indeed, umm, visibly blank!
Online man page here.
I wanted this output to look like a proper spreadsheet
If you want to make things even more spreadsheet-like, I would suggest you check out Python and the beautifultable module.
Using the above, you can (fairly easy) get output like:
+----------+------+--------+
| name | rank | gender |
+----------+------+--------+
| Jacob | 1 | boy |
+----------+------+--------+
| Isabella | 1 | girl |
+----------+------+--------+
| Ethan | 2 | boy |
+----------+------+--------+
| Sophia | 2 | girl |
+----------+------+--------+
| Michael | 3 | boy |
+----------+------+--------+
I updated my script to include that line ` column -t $file > temp-123.txt`
â Emile
Aug 10 at 16:26
When I try to email this file as the body of the email, i lose the formatting from the column command. Do you know how to retain that formatting?
â Emile
Aug 10 at 16:55
Try using a fixed width font in your e-mail client.
â RudiC
Aug 10 at 17:09
Is there a way to make column output the last|in every row, even whenConfirmationis empty? I think that would look nicer.
â confetti
Aug 11 at 5:12
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
I'm unsure how to make the lines match up
Have a look at column.
Original file
$ cat columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
With column
$ column -t columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
As you can see from above, using column makes the output align nicely, and the blank Confirmation column is indeed, umm, visibly blank!
Online man page here.
I wanted this output to look like a proper spreadsheet
If you want to make things even more spreadsheet-like, I would suggest you check out Python and the beautifultable module.
Using the above, you can (fairly easy) get output like:
+----------+------+--------+
| name | rank | gender |
+----------+------+--------+
| Jacob | 1 | boy |
+----------+------+--------+
| Isabella | 1 | girl |
+----------+------+--------+
| Ethan | 2 | boy |
+----------+------+--------+
| Sophia | 2 | girl |
+----------+------+--------+
| Michael | 3 | boy |
+----------+------+--------+
I updated my script to include that line ` column -t $file > temp-123.txt`
â Emile
Aug 10 at 16:26
When I try to email this file as the body of the email, i lose the formatting from the column command. Do you know how to retain that formatting?
â Emile
Aug 10 at 16:55
Try using a fixed width font in your e-mail client.
â RudiC
Aug 10 at 17:09
Is there a way to make column output the last|in every row, even whenConfirmationis empty? I think that would look nicer.
â confetti
Aug 11 at 5:12
add a comment |Â
up vote
5
down vote
I'm unsure how to make the lines match up
Have a look at column.
Original file
$ cat columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
With column
$ column -t columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
As you can see from above, using column makes the output align nicely, and the blank Confirmation column is indeed, umm, visibly blank!
Online man page here.
I wanted this output to look like a proper spreadsheet
If you want to make things even more spreadsheet-like, I would suggest you check out Python and the beautifultable module.
Using the above, you can (fairly easy) get output like:
+----------+------+--------+
| name | rank | gender |
+----------+------+--------+
| Jacob | 1 | boy |
+----------+------+--------+
| Isabella | 1 | girl |
+----------+------+--------+
| Ethan | 2 | boy |
+----------+------+--------+
| Sophia | 2 | girl |
+----------+------+--------+
| Michael | 3 | boy |
+----------+------+--------+
I updated my script to include that line ` column -t $file > temp-123.txt`
â Emile
Aug 10 at 16:26
When I try to email this file as the body of the email, i lose the formatting from the column command. Do you know how to retain that formatting?
â Emile
Aug 10 at 16:55
Try using a fixed width font in your e-mail client.
â RudiC
Aug 10 at 17:09
Is there a way to make column output the last|in every row, even whenConfirmationis empty? I think that would look nicer.
â confetti
Aug 11 at 5:12
add a comment |Â
up vote
5
down vote
up vote
5
down vote
I'm unsure how to make the lines match up
Have a look at column.
Original file
$ cat columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
With column
$ column -t columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
As you can see from above, using column makes the output align nicely, and the blank Confirmation column is indeed, umm, visibly blank!
Online man page here.
I wanted this output to look like a proper spreadsheet
If you want to make things even more spreadsheet-like, I would suggest you check out Python and the beautifultable module.
Using the above, you can (fairly easy) get output like:
+----------+------+--------+
| name | rank | gender |
+----------+------+--------+
| Jacob | 1 | boy |
+----------+------+--------+
| Isabella | 1 | girl |
+----------+------+--------+
| Ethan | 2 | boy |
+----------+------+--------+
| Sophia | 2 | girl |
+----------+------+--------+
| Michael | 3 | boy |
+----------+------+--------+
I'm unsure how to make the lines match up
Have a look at column.
Original file
$ cat columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
With column
$ column -t columns.txt
Identify | Misc | Date | Amount | Confirmation
SOMETHING5 | 11111111 | 1969-08-12 | 42.34
SOMETHING4 | 22222222 | 1969-08-12 | 700.12
SOMETHING3 | 333333333 | 1969-08-12 | 300.2
SOMETHING2 | 44444444444 | 1969-08-12 | 200.2
SOMETHING1 | 5555555555 | 1969-08-12 | 100.34
As you can see from above, using column makes the output align nicely, and the blank Confirmation column is indeed, umm, visibly blank!
Online man page here.
I wanted this output to look like a proper spreadsheet
If you want to make things even more spreadsheet-like, I would suggest you check out Python and the beautifultable module.
Using the above, you can (fairly easy) get output like:
+----------+------+--------+
| name | rank | gender |
+----------+------+--------+
| Jacob | 1 | boy |
+----------+------+--------+
| Isabella | 1 | girl |
+----------+------+--------+
| Ethan | 2 | boy |
+----------+------+--------+
| Sophia | 2 | girl |
+----------+------+--------+
| Michael | 3 | boy |
+----------+------+--------+
edited Aug 10 at 16:38
answered Aug 10 at 16:14
maulinglawns
6,0032924
6,0032924
I updated my script to include that line ` column -t $file > temp-123.txt`
â Emile
Aug 10 at 16:26
When I try to email this file as the body of the email, i lose the formatting from the column command. Do you know how to retain that formatting?
â Emile
Aug 10 at 16:55
Try using a fixed width font in your e-mail client.
â RudiC
Aug 10 at 17:09
Is there a way to make column output the last|in every row, even whenConfirmationis empty? I think that would look nicer.
â confetti
Aug 11 at 5:12
add a comment |Â
I updated my script to include that line ` column -t $file > temp-123.txt`
â Emile
Aug 10 at 16:26
When I try to email this file as the body of the email, i lose the formatting from the column command. Do you know how to retain that formatting?
â Emile
Aug 10 at 16:55
Try using a fixed width font in your e-mail client.
â RudiC
Aug 10 at 17:09
Is there a way to make column output the last|in every row, even whenConfirmationis empty? I think that would look nicer.
â confetti
Aug 11 at 5:12
I updated my script to include that line ` column -t $file > temp-123.txt`
â Emile
Aug 10 at 16:26
I updated my script to include that line ` column -t $file > temp-123.txt`
â Emile
Aug 10 at 16:26
When I try to email this file as the body of the email, i lose the formatting from the column command. Do you know how to retain that formatting?
â Emile
Aug 10 at 16:55
When I try to email this file as the body of the email, i lose the formatting from the column command. Do you know how to retain that formatting?
â Emile
Aug 10 at 16:55
Try using a fixed width font in your e-mail client.
â RudiC
Aug 10 at 17:09
Try using a fixed width font in your e-mail client.
â RudiC
Aug 10 at 17:09
Is there a way to make column output the last
| in every row, even when Confirmation is empty? I think that would look nicer.â confetti
Aug 11 at 5:12
Is there a way to make column output the last
| in every row, even when Confirmation is empty? I think that would look nicer.â confetti
Aug 11 at 5:12
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461842%2fcan-i-change-a-text-file-into-a-spreadsheet-with-grid-lines-using-a-bash-script%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password