Jump to content

CSV Viewer


llewxam
 Share

Recommended Posts

I could swear that I saw someone else had a CSV viewer script posted but no amount of searching found it. If someone knows of one that has been done before, please post a link to it.

I write many scripts that save information to CSV files, but got tired of using Excel to view them because of having to resize the columns to view all of the information. Yes there are ways of resizing the columns, but I decided to write a viewer to make life a little easier.

There are some configurable options, such as font used, font size, weight, and underlining, as well as optional automatic column width resizing thanks to Melba23's StringSize UDF, now built-in rather than having to download the UDF.

Please be aware that when using the resize option it will take about twice as long to run the script. For a fairly sane file it is not at all a big deal, but feed it an 8MB file with 130 columns and 11,500 rows (about 1.5 million elements) and it takes quite a long time!! :) This script also takes a lot of RAM to run, the 8MB file I used above took over 200MB of RAM.

I'd like to see other ideas, so please post 'em if you got 'em.

Enjoy

Ian

EDIT: Updated code

CSV Viewer.zip

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

I could swear that I saw someone else had a CSV viewer script posted but no amount of searching found it. If someone knows of one that has been done before, please post a link to it.

Here:

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I use UDF written by progandy to split a CSV into an array.

To display the array I simply use _ArrayDisplay. No resizing etc. and I don't know how it works with large files but it might give you an idea.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@UEZ:

Thanks for that, but on my torture test 8MB file he had an array overflow, so will get in touch with him. Also, his defaults to semicolon delimiter, odd since the point is a C-SV, not an S-SV :) Still, I understand the point of him allowing a selectable delimiter and it is a cool idea......

@water:

The splitting is the easy part, no need for anything beyond StringSplt as far as I can work out, but will look at that UDF anyway to see what it has going on. Thanks.

@czardas:

I was contemplating a resizable GUI but have never done that yet, so decided to not try now. Maybe a re-write of this would be a good time to try. As for opening a new file from the GUI, also a good idea so that will also go in to the "next rewrite" box.

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

CSV / SSV: this is historical to middle europe because the default delimiter here is ; and not , but it can be changed easily.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

:) Interesting, did not know that. Perhaps I should add that as an option then!

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

Hmm, array overflow. I fear suffer the same issues. I haven't really tested the limits. I think it will handle several million fields though. It might be slow to test it (better to calculate it).

The format csv has several rules about enclosing the delimeter (commas) within fields. A simple stringsplit will not work on many csv files because of this.

Link to comment
Share on other sites

ProgAndy's failed the 8MB test, the array got too big, but yours passed the 8MB test, and the super-test 24MB that was the original 8MB copied 3 times. Nice job! :) I will look in to incorporating it.

Thanks!

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

I think ProgAndy's code looks quite sophisticated compaired to mine. I don't really understand why it would not handle the same amount of data. It has encoding options which I think I ought to try. Anyway I look forward to seeing your next release. Any problems with the UDF, just ask.

Link to comment
Share on other sites

Add error handling

$File = FileOpenDialog("Select a CSV File", @DesktopDir, "CSV Files (*.csv)")
If @error Then Exit

Example

#include <ListViewConstants.au3>
$sText= _
'foo,bar,555,"foo,bar",1,2,3' & @CRLF & _
' ;),test,098765,"o),yes","4,3",5,6'
; MsgBox(0, '?', $sText)

$sep = Chr(1)
$sText=StringRegExpReplace($sText, ',(?=(?:[^"]*"[^"]*")*(?![^"]*"))', $sep)

$hGui = GUICreate('My Program', 550, 260)

$aLine=StringSplit($sText, @CRLF, 1)
$iCount = StringSplit($aLine[1], $sep)
$sHeader = ''
For $i = 1 To $iCount[0]
    $sHeader &= $i & '|'
Next
$sHeader = StringTrimRight($sHeader, 1)
$iListView = GUICtrlCreateListView($sHeader, 0, 0, 550, 260 - 30)

$sOptSepDef = Opt('GUIDataSeparatorChar', $sep)
For $i = 1 To $aLine[0]
    GUICtrlCreateListViewItem($aLine[$i], $iListView)
Next
Opt('GUIDataSeparatorChar', $sOptSepDef)
For $i = 0 To $iCount[0]
    GUICtrlSendMsg($iListView, $LVM_SETCOLUMNWIDTH, $i, -1)
    GUICtrlSendMsg($iListView, $LVM_SETCOLUMNWIDTH, $i, -2)
Next
GUISetState()
Do
Until GUIGetMsg() = -3
Edited by AZJIO
Link to comment
Share on other sites

You always come up with really nice looking code AZJIO, and your example works well on consistent CSVs, but it couldn't properly display on my mini-test 69 row 3 column CSV because the first line is only 2 columns, but there are some rows that have 3 though. Your script assumes consistency with the way $iCount is determined. ;) With my mid-sized test it wouldn't finish at all, very strange error code came up, 1073741571.

It is very impressive though how small the code is!

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

I think ProgAndy's code looks quite sophisticated compaired to mine. I don't really understand why it would not handle the same amount of data. It has encoding options which I think I ought to try. Anyway I look forward to seeing your next release. Any problems with the UDF, just ask.

I know why my UDF does not work with your file. First, it creates an array which can hold all available fields as single records, afterwards it adds a column if required and does not reduce allocated space in the first dimension. This is done only at the very end.

To fix that, you'll have to cut down the record count of the array when adding an additional column which forces some more error checking in return.

Edit: improved wording. I have a fixed version and currently am running some tests with openURL routing data.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

I know why my UDF does not work with your file. First, it creates an array which can hold all available elements as single entries, afterwards it adds a column if required and does not allocated space in the first dimension. This is done only at the very end.

To fix that, you'll have to cut down the row count of the array when adding an additional column which forces some more error checking in return.

I get the picture, but I'm still a bit fuzzy on the details. I'll look at it more closely, thanks!

Link to comment
Share on other sites

First post updated, now using czardas' UDF as well as copied Melba23's StringSize UDF in to the script for ease of use. Thanks all for the suggestions, more revisions may come.

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

First post updated, probably the last update as far as new features go, but then again, when is a script ever "done"????? :)

Revamped GUI which looks much better and allows all options to be configured from the GUI, rather than through the code. Much more likely to be useful now because of this!

Any issues please let me know, otherwise enjoy.

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

It's much better now you have added the menu. It's true that you can add no end of features. I have an unfinished program similar to this. One of the most useful features I have found (with my program) is being able to sort by clicking on a column header - just another thought. :)

Edited by czardas
Link to comment
Share on other sites

doooohhh, don't give me ideas, then it will NEVER be finished!!! hahahahaha

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

Here some more ideas to implement:

  • add 1st row of csv to column header
  • different line color (odd / even)
  • resizeable window
  • sort option when clicked on a column header
  • search functionality

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...