Visual CSV Reader什么不能保持文件“打开”

时间:2013-11-11 13:46:35

标签: excel csv notepad++

我正在寻找一种方法来查看CSV文件,就像在Excel中一样(很好的清晰布局)Excel的唯一问题是它不会通知您更新,也不会在文件“打开”后关闭文件与Notepad ++不同,它允许您查看文件何时更新,并且它还允许您打开文件,然后在python中操作它...

Notepad ++唯一的问题是无法轻松阅读CSV。

记事本++

  • 优点
    • “此文件已被其他程序修改过,您要重新加载吗?”
    • 在视觉上加载数据后关闭文件。
    • 可以轻松地与其他文件进行比较。
  • 缺点
    • 没有清晰的视觉观察者。

Excel中

  • 优点
    • 清除可视化查看器。
  • 缺点
    • 一旦数据以可视方式加载,就不会关闭文件。
    • 当文件被其他程序修改时,不会提醒您(如果在Excel中打开文件,则无法对其进行修改)
    • 无法轻易与其他文件进行比较。

有人知道帮助我的计划吗?

之前

data,data,datalongdatadatalongdata,datalongdata,datalongdata,data,data,data,datalongdata,data,data,data,data,datalongdata,datalongdata,data
data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
data,data,data,data,data,data,data,data,data,data,data,data,data,data,datalongdatadatalongdatadatalongdatadatalongdatadatalongdata,data
data,data,data,data,data,data,data,data,data'data,data,data,data,data,data,data,data
data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
data,data,data,data,data,data,data,data,data,data,data,data,data,datalongdatadatalongdatadatalongdatadatalongdata,data,data

之后(查看data'data的第5行)

data,data,datalongdatadatalongdata,datalongdata,datalongdata,data,data,data,datalongdata,data,data,data,data,datalongdata,datalongdata                                                ,data
data,data,data                    ,data        ,data        ,data,data,data,data        ,data,data,data,data,data        ,data                                                        ,data
data,data,data                    ,data        ,data        ,data,data,data,data        ,data,data,data,data,data        ,data                                                        ,data
data,data,data                    ,data        ,data        ,data,data,data,data        ,data,data,data,data,data        ,datalongdatadatalongdatadatalongdatadatalongdatadatalongdata,data
data,data,data                    ,data        ,data        ,data,data,data,data'data,data,data,data,data,data,data,data
data,data,data                    ,data        ,data        ,data,data,data,data,data,data,data,data,data,data,data
data,data,data                    ,data        ,data        ,data,data,data,data,data,data,data,data,data,data,data
data,data,data                    ,data        ,data        ,data,data,data,data,data,data,data,data,datalongdatadatalongdatadatalongdatadatalongdata,data,data

2 个答案:

答案 0 :(得分:5)

您永远无法在Notepad ++中获得Excel的出色视觉体验!

我所知道的唯一“解决方案”位于TextFX插件中。

选择所有文字,然后转到TextFX > TextFX Edit > Line up multiple lines by (,)。这将转换以下示例:

heeey,this,is,a,testtttttttttt
34,3,2234,3,5
123,123,123,123,123

要:

heeey,this,is  ,a  ,testtttttttttt
34   ,3   ,2234,3  ,5
123  ,123 ,123 ,123,123

PS。您可能需要查看CSVed。从来没有必要使用它,所以我不知道它是否具备您需要的所有功能,但从截图看起来它看起来不错:)

答案 1 :(得分:1)

我回来了一个新答案:)在TextFX中发现错误后,我决定使用Python Script插件创建更好的内容。

实施例

它将转换以下示例:

heeey,this,is,a,testtttttttttt
34,3
123,123,123,123,123

要:

+ ----------------------------------------- +
| heeey | this | is  | a   | testtttttttttt |
| 34    | 3    |     |     |                |
| 123   | 123  | 123 | 123 | 123            |
+ ----------------------------------------- +

以下内容:

title1,title2,title3,title4,title5,title6,title7,title8,title9
datalongdata,datalongdata,data,data,data,datalongdata,data,data,data
data,data,data,data,data,data,data,datalongdatadatalongdatadatalongdatadatalongdatadatalongdata,data
data,data'data,data,data,data,data,data,data,data

要:

+ ------------------------------------------------------------------------------------------------------------------------------------------------------ +
| title1       | title2       | title3 | title4 | title5 | title6       | title7 | title8                                                       | title9 |
+ ------------------------------------------------------------------------------------------------------------------------------------------------------ +
| datalongdata | datalongdata | data   | data   | data   | datalongdata | data   | data                                                         | data   |
| data         | data         | data   | data   | data   | data         | data   | datalongdatadatalongdatadatalongdatadatalongdatadatalongdata | data   |
| data         | data'data    | data   | data   | data   | data         | data   | data                                                         | data   |
+ ------------------------------------------------------------------------------------------------------------------------------------------------------ +

安装

  1. Python Scriptofficial website安装Plugin Manager插件。
  2. 安装后,转到Plugins > Python Script > New Script。选择新文件的文件名(例如pretty_csv.py)并复制后面的代码。
  3. 打开csv文件,然后运行Plugins > Python Script > Scripts > pretty_csv.py。这将打开一个带有你的桌子的新标签。
  4. 请注意,在脚本的前几行中,您可以更改一些参数。我希望变量名称是不言自明的!我想最重要的是布尔值,borderheader

    #define parameters
    delimiter=","
    new_delimiter=" | "
    border=True
    border_vertical_left="| "
    border_vertical_right=" |"
    border_horizontal="-"
    border_corner_tl="+ "
    border_corner_tr=" +"
    border_corner_bl="+ "
    border_corner_br=" +"
    header=True
    border_header_separator="-"
    border_header_left="+ "
    border_header_right=" +"
    newline="\n"
    
    #load csv
    content=editor.getText()
    content=content.rstrip(newline)
    rows=content.split(newline)
    
    #find the max number of columns (so having rows with different number of columns is no problem)
    max_columns=max([row.count(delimiter) for row in rows])
    if max_columns>0:
        max_columns=max_columns+1
    
        #find the max width of each column
        column_max_width=[0]*max_columns
        for row in rows:
            for index,column in enumerate(row.split(delimiter)):
                width=len(column)
                if width>column_max_width[index]:
                    column_max_width[index]=width
        total_length=sum(column_max_width)+len(new_delimiter)*(max_columns-1)
    
        #create new document
        notepad.new()
    
        #apply the changes
        left=border_vertical_left if border is True else ""
        right=border_vertical_right if border is True else ""
        left_header=border_header_left if border is True else ""
        right_header=border_header_right if border is True else ""
        for row_number,row in enumerate(rows):
            columns=row.split(delimiter)
            max_index=len(columns)-1
            for index in range(max_columns):
                if index>max_index:
                    columns.append(' ' * column_max_width[index])
                else:
                    diff=column_max_width[index]-len(columns[index])
                    columns[index]=columns[index] + ' ' * diff
    
            if row_number==0 and border is True: #draw top border
                editor.addText(border_corner_tl + border_horizontal * total_length + border_corner_tr + newline)
            editor.addText(left + new_delimiter.join(columns) + right + newline) #print the new row
            if row_number==0 and header is True: #draw header's separator
                editor.addText(left_header + border_header_separator * total_length + right_header + newline)
            if row_number==len(rows)-1 and border is True: #draw bottom border
                editor.addText(border_corner_bl + border_horizontal * total_length + border_corner_br)
    else:
        console.clear()
        console.show()
        console.writeError("No \"%s\" delimiter found!" % delimiter)
    

    如果您发现任何错误或有任何建议,请告诉我们!