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

The name of the pictureThe name of the pictureThe name of the pictureClash 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.










share|improve this question



























    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.










    share|improve this question

























      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.










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 10 at 16:33









      Jesse_b

      10.5k22659




      10.5k22659










      asked Aug 10 at 16:05









      Emile

      989




      989




















          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 |
          +----------+------+--------+





          share|improve this answer






















          • 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 when Confirmation is empty? I think that would look nicer.
            – confetti
            Aug 11 at 5:12










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          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






























          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 |
          +----------+------+--------+





          share|improve this answer






















          • 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 when Confirmation is empty? I think that would look nicer.
            – confetti
            Aug 11 at 5:12














          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 |
          +----------+------+--------+





          share|improve this answer






















          • 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 when Confirmation is empty? I think that would look nicer.
            – confetti
            Aug 11 at 5:12












          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 |
          +----------+------+--------+





          share|improve this answer















          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 |
          +----------+------+--------+






          share|improve this answer














          share|improve this answer



          share|improve this answer








          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 when Confirmation is 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










          • 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 when Confirmation is 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

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)