CSV Quick Filter v0.39r
Download:
https://ahknet.autoh...ilter/csvqf.zip
(consists of one AHK file + modified CSV lib (with bug fixes) + Attach lib by majkinetor)
This script allows you to load a CSV file (any delimited file)
and use various search criteria to filter the listview.
You can export the results to a new file.
Note: an entire row of the CSV is searched at once and not
on a cell by cell basis to provide faster search results.
For large files it will be fairly slow, it will also depend on your PC specs how fast it will display all the results.
Updated (0.38i) Command line options:
Command line options:
CSVQF file ["delimiter"] ["header"] ["Columns to use in CSV"]
Example, opening a | delimited file:
CSVQF data.csv "|"
Use the first row as header for listview: (header = 1,Y,Yes,T,True)
CSVQF data.csv "," "1"
Use \t for a tab delimited file
CSVQF tabdata.txt "\t"
Only use specific columns (1 & 5):
CSVQF data.csv "," "0" "1,5"
or run CSVQF.ahk, select a file and select your preferences.
CSV Quick Filter (GUI) show results in listview as you type
Started by
SoLong&Thx4AllTheFish
, Jun 21 2011 09:02 PM
34 replies to this topic
Update:
- much nicer startup gui with fileselect, default delimiter options
- you can define which columns and the order you wish to display them*
- should be a bit faster for large® datasets
* uses code by jsherk <!-- m -->http://www.autohotke...pic.php?t=73246<!-- m --> to filter input, very nice idea - thx
- much nicer startup gui with fileselect, default delimiter options
- you can define which columns and the order you wish to display them*
- should be a bit faster for large® datasets
* uses code by jsherk <!-- m -->http://www.autohotke...pic.php?t=73246<!-- m --> to filter input, very nice idea - thx
#2
-
Posted 01 July 2011 - 09:11 PM
this is for me
CSV_Load(FileName, CSV_Identifier="", Delimiter="`,") { Local Row Local Col temp := %CSV_Identifier%CSVFile FileRead, temp, %FileName% StringReplace, temp, temp, `r`n`r`n, `r`n, all ;Remove all blank lines from the CSV file Loop, Parse, temp, `n, `r { ;Exclude space [color=red] If A_LoopField is space Continue[/color] Col := ReturnDSVArray(A_LoopField, CSV_Identifier . "CSV_Row" . A_Index . "_Col", Delimiter) ;MAX hold [color=red] If (col < O_col) col := O_col Else O_col := col [/color] Row := A_Index Loop, Parse, A_LoopReadLine, %Delimiter% { Col := A_Index %CSV_Identifier%CSV_Row%Row%_Col%Col% := A_LoopField } } %CSV_Identifier%CSV_TotalRows := Row %CSV_Identifier%CSV_TotalCols := Col %CSV_Identifier%CSV_Delimiter := Delimiter SplitPath, FileName, %CSV_Identifier%CSV_FileName, %CSV_Identifier%CSV_Path IfNotInString, FileName, `\ { %CSV_Identifier%CSV_FileName := FileName %CSV_Identifier%CSV_Path := A_ScriptDir } %CSV_Identifier%CSV_FileNamePath := %CSV_Identifier%CSV_Path . "\" . %CSV_Identifier%CSV_FileName }
#3
-
Posted 02 July 2011 - 04:26 PM
Is it possible to change the Column headers to be actual Column headers from the CSV file. I've been trying to modify your code to, but cant seem to get it right.
#4
-
Posted 25 August 2011 - 11:16 PM
@Nutss: yes, that should be possible I'll have a stab at it over the weekend.
#5
-
Posted 26 August 2011 - 07:33 AM
Thz, i was actually able to find where the header labeling was being generated and just hardcoded it in, since my list wouldnt be changing.
I did have another question about the listview. As you filter through your search ive noticed that though the list isnt showing the csv data for rows not relevant, it does still have the blank rows present. And when you sort you current list the blank rows will take priority. Is it possible to get rid of those blank rows?
Thanks again.
I did have another question about the listview. As you filter through your search ive noticed that though the list isnt showing the csv data for rows not relevant, it does still have the blank rows present. And when you sort you current list the blank rows will take priority. Is it possible to get rid of those blank rows?
Thanks again.
#6
-
Posted 27 August 2011 - 12:27 AM
Aug 26, 2011 - Update:
* CHANGE: new cmdline paramater for header row, and order has changed see HELP (see 2nd point below)
+ Option to use (first) header row as listview headers (via start gui + cmdline)
+ Gui can now be resized. Uses Attach by majkinetor <!-- m -->http://www.autohotke... ... ight=forms<!-- m -->
+ Gui starts maximized
+ File history in startup Gui. Data saved in file CSVQF.history (you can delete it if you wish)
+ Alt-f sets focus back to filter control
+ No more empty rows in search results, helps with sorting
+ FAST negative results: simply look in entire file before processing all rows :-) (does double memory usage, but who cares)
See links in first post
* CHANGE: new cmdline paramater for header row, and order has changed see HELP (see 2nd point below)
+ Option to use (first) header row as listview headers (via start gui + cmdline)
+ Gui can now be resized. Uses Attach by majkinetor <!-- m -->http://www.autohotke... ... ight=forms<!-- m -->
+ Gui starts maximized
+ File history in startup Gui. Data saved in file CSVQF.history (you can delete it if you wish)
+ Alt-f sets focus back to filter control
+ No more empty rows in search results, helps with sorting
+ FAST negative results: simply look in entire file before processing all rows :-) (does double memory usage, but who cares)
See links in first post
#7
-
Posted 30 August 2011 - 05:06 PM
Thank you very much. I really appreciate your work!
#8
-
Posted 06 September 2011 - 11:41 PM
Thank you Hugov, bookmarked!
#9
-
Posted 07 September 2011 - 06:39 AM
Glad you like it
Sep 07, 2011 Update:
- Removed spinning "Indicator" -> Dramatic speed improvement for larger CSV files.
Sep 07, 2011 Update:
- Removed spinning "Indicator" -> Dramatic speed improvement for larger CSV files.
#10
-
Posted 08 September 2011 - 07:59 PM
I am using 1.0.48.05 and at line 518, for v in files, I get the error "Error: this line does not contain a recognized action".
Do I need ahk-l? :?:
Do I need ahk-l? :?:
#11
-
Posted 14 September 2011 - 09:33 PM
Yes, I'm using ahk_l array there, was so much easier compared to a psuedo array. You'll loose the history though.
You could comment lines 516-530, 659-663, 668-677 or simply download the ZIP version of ahk_l to try it out. (just unzip, copy to csvqf folder and run autohotkey.exe csvqf.ahk)
If you do run basic you have to #include attach.ahk and csv.ahk or move them to your lib folder.
or download a compiled version here <!-- m -->https://ahknet.autoh... ... rtable.zip<!-- m -->
You could comment lines 516-530, 659-663, 668-677 or simply download the ZIP version of ahk_l to try it out. (just unzip, copy to csvqf folder and run autohotkey.exe csvqf.ahk)
If you do run basic you have to #include attach.ahk and csv.ahk or move them to your lib folder.
or download a compiled version here <!-- m -->https://ahknet.autoh... ... rtable.zip<!-- m -->
#12
-
Posted 14 September 2011 - 09:43 PM
Thank you very much, this is a great program!
How could I restrict search to the "last" column only? By "last" I mean the first element from the right, which could correspond to differently-numbered columns. Consider this example, where each data line is a fullpath:
csvqf.exe data.csv "\\" "$"
(I just made up a syntax for last column, "$"); this example would search in filenames only, disregarding the container path no matter how many path elements each container has.
How could I restrict search to the "last" column only? By "last" I mean the first element from the right, which could correspond to differently-numbered columns. Consider this example, where each data line is a fullpath:
csvqf.exe data.csv "\\" "$"
(I just made up a syntax for last column, "$"); this example would search in filenames only, disregarding the container path no matter how many path elements each container has.
#13
-
Posted 12 September 2012 - 04:58 PM
@step: glad you like it. Nice suggestion, I added it, in the search Gui there is now a DDL where you can select ALL or a specific column to search, also some minor tweaks to the startup gui and column headers.
Download version 0.41k here <!-- m -->https://ahknet.autoh... ... /csvqf.zip<!-- m -->
Download version 0.41k here <!-- m -->https://ahknet.autoh... ... /csvqf.zip<!-- m -->
#14
-
Posted 15 September 2012 - 04:05 PM
Hi, thank you for the new version, but this isn't really what I had in mind. It's my fault, I didn't explain myself correctly. Let me try again.@step: glad you like it. Nice suggestion, I added it, in the search Gui there is now a DDL where you can select ALL or a specific column to search
First you need a data.csv file holding full pathnames to a bunch of files; with CMD.exe
dir /b /s C:\SOME-FOLDER > C:\data.csvEnsure that SOME-FOLDER includes other folders because we want to test paths with varying number of components. By component I mean a string between pairs of excluded backslashes, like \dir1\, or the filename component of a path, like (just the bold text) ...\dir\FILENAME.EXT.
Our goal is to match just the filename component. Obviously a fixed column number won't do because a filename occurs in different column numbers depending on the path length. But if we had a way to say, "I want the last column", say that the last column is referenced by the special symbol "$", then we could just say, "Match pattern in column $". That's the gist of my question, could it be done?
Here's a sample data.csv
C:\dir\dir1\file1.txt C:\dir\dir1\file2.txt C:\dir\dir1\dir11\file3.txtLaunching csvqf.awk data.csv "\\" "$" and
LOOKING FOR YIELDS THE FULL ROWS OF txt file1.txt, file2.txt, file3.txt dir nothingWe're matching the "last" column only - not columns "4,5" at once.
While launching csvqf.awk data.csv "\\" "4" and
LOOKING FOR YIELDS THE FULL ROWS OF txt file1.txt, file2.txt dir file3.txt (actually dir11)File3.txt is excluded from "txt" because txt is in column 5. File3.txt is included in "dir" because dir11 is in column 4.
Sorry again for the confusion.
#15
-
Posted 17 September 2012 - 05:35 AM