This is a quick script to make reading through CSVs in notepad++ easier.
I often just need to quickly look down for a value, and opening Excel or OOCalc is time consuming.
a=[[]forxineditor.getLine(1).split(",")]defcsv_to_list(cont,l_num,tot_lines):cont=cont.split(",")forninrange(len(cont)):a[n].append(cont[n].replace("\r\n",""))editor.forEachLine(csv_to_list)aLens=[max([len(x) for x in a[y]])foryinrange(len(a))]defform_line(l_num):txt="".join([a[x][l_num].ljust(aLens[x]+1)forxinrange(len(aLens))])txt=txt+"\r\n"return(txt)notepad.new()forlinrange(len(a[0])-1):editor.addText(form_line(l))
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Python 2.7.1 (release27-maint-npp, Feb 6 2011, 16:58:20)
Initialisation took 609ms
Ready.
Traceback (most recent call last):
File "C:\Users\Robert Vos\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\csvsplit.py", line 6, in <module>
editor.forEachLine(csv_to_list)
File "C:\…\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\csvsplit.py", line 4, in csv_to_list
for n in range(len(cont)): a.append(cont.replace("\r\n", ""))
IndexError: list index out of range
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That appears to occur if you've got one (or more) lines with a different number of fields in - bear in mind also that the script doesn't cope with quoted data - so
"hello","there","jones,dave"
The last "field" (jones,dave), would be treated as two. Perhaps someone, maybe the original author, can suggest an improvement to the script…
Cheers,
Dave.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the reply. My data contains variable lenght records (a variable number of columns) and is quoted.
I have tried to solve it with Notepad, making use of Text Fx edit. Bbut (I think) because I use UTF-8 encoded data, the aligment function (Line up by multiple lines) does not work correctly.
I have solved the readability with: uniCSVed, but now I miss my other Notepad++ functions.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a quick script to make reading through CSVs in notepad++ easier.
I often just need to quickly look down for a value, and opening Excel or OOCalc is time consuming.
You can also use CSVEd to easily access, view and edit CSV files:
http://csved.sjfrancke.nl
"Comma Separated Values, Color each column" (Open Discussion Forum)
http://sourceforge.net/projects/notepad-plus/forums/forum/331753/topic/3035285
I received an error while trying your script :
Python 2.7.1 (release27-maint-npp, Feb 6 2011, 16:58:20)
Initialisation took 609ms
Ready.
Traceback (most recent call last):
File "C:\Users\Robert Vos\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\csvsplit.py", line 6, in <module>
editor.forEachLine(csv_to_list)
File "C:\…\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\csvsplit.py", line 4, in csv_to_list
for n in range(len(cont)): a.append(cont.replace("\r\n", ""))
IndexError: list index out of range
That appears to occur if you've got one (or more) lines with a different number of fields in - bear in mind also that the script doesn't cope with quoted data - so
"hello","there","jones,dave"
The last "field" (jones,dave), would be treated as two. Perhaps someone, maybe the original author, can suggest an improvement to the script…
Cheers,
Dave.
Thanks for the reply. My data contains variable lenght records (a variable number of columns) and is quoted.
I have tried to solve it with Notepad, making use of Text Fx edit. Bbut (I think) because I use UTF-8 encoded data, the aligment function (Line up by multiple lines) does not work correctly.
I have solved the readability with: uniCSVed, but now I miss my other Notepad++ functions.