12

This question already has an answer here:

When we paste a table from a note pad or word or any other source its not coming in a good table format in this Stack Overflow question editor/text box space. My question is how do you make an unscrambled table (good format table) here. What do you do to make this happen? For example I paste the following table from Notepad, but it looks non-understandable:

ID LinkID PC TotalnoofoccurenceofID

10R46 R*1005 8017 2
10R46 R*10335 5019 2
100R91 R*1005 8017 1
10R91 R*243 8870 1
10M95 R*4918 8305 3
10M95 R*9017 8305 3
10M95 R*9470 8221 3

I saw some people changed this into a good HTML-like table format.

marked as duplicate by user213963, Martijn Pieters, Hugo Dozois, Aaron Bertrand, Jonathan Leffler Feb 9 '14 at 6:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Feb 9 '14 at 3:05

This question came from our site for professional and enthusiast programmers.

  • you can use <pre></pre> tag, around your table – Kannan Ramamoorthy Jan 18 '17 at 9:12
14
  1. Make sure the table's columns are separated by spaces — no tabs.
  2. Double check that there are no tabs.
  3. Make sure once more that there are no tabs.
  4. Make sure the table looks sane in a monowidth font (Courier or equivalent).
  5. Check that there are no tabs.
  6. Copy the table from the editor to the question or answer.
  7. Select the table.
  8. Press the {} button above the edit box to indent it as code.
  9. Use 2 spaces to separate columns; you can use 3 or 4 if the table will fit across the page, but not more.
  10. Avoid the horizontal scroll bar if at all possible.

Did I mention making sure there are no tabs in the data?

ID      LinkID   PC    TotalNoOfOccurencesOfID
10R46   R*1005   8017  2
10R46   R*10335  5019  2
100R91  R*1005   8017  1
10R91   R*243    8870  1
10M95   R*4918   8305  3
10M95   R*9017   8305  3
10M95   R*9470   8221  3
  • 4
    Should I check to make sure there are no tabs? – TARKUS Apr 22 '17 at 14:04
  • 1
    If you haven't checked a couple of times already, another check is probably a good idea. – Jonathan Leffler Apr 22 '17 at 14:06
  • 1
    I'm using this answer as my tutorial on the subject. – TARKUS Apr 22 '17 at 14:07
8

To add to the fixed-width idea, if you have lots of data (mostly not a good idea, but it does happen...). you can use two code blocks to make sure the header is always visible.

    ID      LinkID   PC    TotalNoOfOccurencesOfID

<!-- -->

    10R46   R*1005   8017  2
    10R46   R*10335  5019  2
    100R91  R*1005   8017  1
    10R91   R*243    8870  1
    10M95   R*4918   8305  3
    10M95   R*9017   8305  3
    10M95   R*9470   8221  3

displays as

ID      LinkID   PC    TotalNoOfOccurencesOfID
10R46   R*1005   8017  2
10R46   R*10335  5019  2
100R91  R*1005   8017  1
10R91   R*243    8870  1
10M95   R*4918   8305  3
10M95   R*9017   8305  3
10M95   R*9470   8221  3

Again, you should rarely have enough data that this should matter, but sometimes you do (scroll down a bit; it's under the heading Additional Support).

  • Note that the mobile theme uses neither scrollbars (but line wrapping), nor a fixed width font (a recent change; maybe a bug). Wide or tall code blocks are simply unreadable there. – Arjan Feb 9 '14 at 8:00
  • Ah, the lack of a fixed width font is only a problem on some devices. The lack of scrollbars is by design though. – Arjan Feb 9 '14 at 8:08