title: How to vertically align tabulator separated values in Notepad++
body: <p>I have a txt file with 406'000 lines (100MB size) and would like to view it with Notepad++ instead of Excel, because it's much faster.</p>
  <p>How can I separate columns with a tabulator delimiter?</p>
  <p>I'm refering to this post:
  <a href="https://stackoverflow.com/questions/45165105/how-to-vertically-align-comma-separated-values-in-notepad">How to vertically align comma separated values in Notepad++?</a></p>
  <p>I really appreciate the answer from zerokelvin:</p>
  <blockquote>
  
  <p>You can use this python plugin script which utilizes the csv library
  which takes care of quoted csv and many other variants.</p>
  <p>Setup:</p>
  <hr />
  <ol>
  <li>Use the plugin manager in Notepad++ to install the &quot;Python script&quot; plugin.</li>
  <li>Plugins-&gt;Python Script-&gt;New Script (name it something like CSVtoTable.py)</li>
  <li>Paste the following python script into the new file and save:</li>
  </ol>
  <p>CSVtoTable.py</p>
  <pre class="lang-py prettyprint-override"><code>import csv
  
  inputlines = editor.getText().split('\n')
  # Get rid of empty lines
  inputlines = [line.strip() for line in inputlines if line.strip()]
  reader = csv.reader(inputlines, delimiter=',')
  csvlist = [line for line in reader]
  # transpose to calculate the column widths and create a format string which left aligns each row
  t_csvlist = zip(*csvlist)
  col_widths = [max([len(x) for x in t_csvlist[y]]) for y in range(len(t_csvlist))]
  # To right align - change &lt; to &gt;
  fmt_str = ' '.join(['{{:&lt;{0}}}'.format(x) for x in col_widths]) + '\r\n'
  
  text = []
  for line in csvlist: 
      text.append(fmt_str.format(*line))
  
  # open a new document and put the results in there.    
  notepad.new()
  editor.addText(''.join(text))
  </code></pre>
  <ol start="4">
  <li>Open your CSV file in notepad++</li>
  <li>Click on Plugins-&gt;Python Script-&gt;Scripts-&gt;(The name you used in step 2)</li>
  <li>A new tab with the formatted data should open.</li>
  </ol>
  <p>Update (right aligned numbers &amp; left aligned strings):
  ------- Use the following python script if you want to right align number fields from the CSV - it looks at the second line of the csv to
  determine the types of the fields.</p>
  <pre class="lang-py prettyprint-override"><code>import csv
  import re
  
  num_re = re.compile('[-\+]?\d+(\.\d+)?')
  
  inputlines = editor.getText().split('\n')
  # Get rid of empty lines
  inputlines = [line.strip() for line in inputlines if line.strip()]
  reader = csv.reader(inputlines, delimiter=',')
  csvlist = [line for line in reader]
  
  # Transpose to calculate the column widths and create a format string which left aligns each row
  t_csvlist = zip(*csvlist)
  col_widths = [max([len(x) for x in t_csvlist[y]]) for y in range(len(t_csvlist))]
  
  # Numbers get right aligned
  type_eval_line = csvlist[1 if len(csvlist)&gt;1 else 0]
  alignment = ['&gt;' if num_re.match(item) else '&lt;' for item in type_eval_line]
  
  # Compute the format string
  fmt_str = ' '.join(['{{:{0}{1}}}'.format(a,x) for x,a in zip(col_widths,alignment)]) + '\r\n'
  
  text = []
  for line in csvlist: 
      text.append(fmt_str.format(*line))
  
  # open a new document and put the results in there.    
  notepad.new()
  editor.addText(''.join(text))
  </code></pre>
  </blockquote>
  <p>How can this Python script be modified if the delimiter is not a comma but a tabulator?</p>
  <p>Addendum (Data File):</p>
  <pre class="lang-py prettyprint-override"><code>Rec#    Cyc#    Step    TestTime    StepTime    Amp-hr  Watt-hr Amps    Volts   State   ES  DPt Time    ACImp/Ohms  DCIR/Ohms   Aux #1   Units  VAR1    VAR2    VAR3    VAR4    VAR5    VAR6    VAR7    VAR8    VAR9    VAR10   VAR11   VAR12   VAR13   VAR14   VAR15   
  1   0   1     0d 00:00:0.140000000596046      0d 00:00:0.140000000596046    0.00001 0.00005 0.00000 3.41497 R   0   08/14/2017 16:42:26 0.00000 0.00000 12.71681            0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 
  2   0   1     0d 00:00:0.140000000596046      0d 00:00:0.140000000596046    0.00001 0.00005 0.00000 3.41497 R   1   08/14/2017 16:42:26 0.00000 0.00000 12.71681            0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 
  </code></pre>