PINTO1927

GUICtrlCreateListViewItem all file *.txt

12 posts in this topic

 

Hello guys, I would have the need to import into the GUICtrlCreateListView all * .txt files in a folder. The * .txt files contain all of the same formatting separated by "|", the script should go on every single file and bring me back the result in the GUICtrlCreateListView. For now I only managed to upload a single file * .txt into the GUICtrlCreateListView with this code:

Case $Button_Find
   $File_txt = "\\cond\UPDATE\test.txt"
   Dim $Array_List
   _FileReadToArray($File_txt, $Array_List)
   $Limit_Array = UBound($Array_List) - 1
   For $i = 1 To $Limit_Array
      $All_Box = String($Array_List[$i])
      GUICtrlCreateListViewItem($All_Box, $List)
   Next
   For $i2 = 0 To _GUICtrlListView_GetColumnCount($List)
   _GUICtrlListView_SetColumnWidth($List, $i2, $LVSCW_AUTOSIZE_USEHEADER)
   Next

:sweating:

Share this post


Link to post
Share on other sites



PINTO1927,

Quote

all * .txt files in a folder

So use _FileListToArray to get the list of files and then loop through the array to read each of them in turn using your existing _FileReadToArray code to extract the data..

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

For now I can only get the name of each .txt file. To get the contents of each file and place it in GUICtrlCreateListView I tried using FileOpen and FileRead but I can not get the result I want.

Can you show me an example? Thank's

Share this post


Link to post
Share on other sites

PINTO1927,

Try using _FileReadToArray to get the content of each file - then you can loop through that array and add each one in turn. Just be careful to use a different loop variable in the nested loops.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

 

i'm becoming crazy.. :mad:

Share this post


Link to post
Share on other sites

PINTO1927,

So what code have you tried using _FileReadToArray that has not worked?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

 

I'm trying to study _FileListToArray("\\cond\UPDATE\", "*.txt", 0 ) to add in code.

 

I can not get results..

Do you have a silly example to show me?:sweating:

 

Share this post


Link to post
Share on other sites

PINTO1927,

Take a look at this:

#include <File.au3>

; Read the intial files into an array
Local $aFiles = _FileListToArray(@ScriptDir, "Test*.txt", $FLTA_FILES, True)

; Now loop through these files
Local $aLines
For $i = 1 To $aFiles[0]
    ; And read their content into an array
    _FileReadtoArray($aFiles[$i], $aLines)
    ; Now loop through the content
    For $j = 1 To $aLines[0]
        ; And extract each line in turn
        ConsoleWrite($aLines[$j] & @CRLF)
    Next
Next

I used these files: Test1.txt Test2.txt Test3.txt for testing.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

PINTO1927,

Glad I could help.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

 

Sorry Melba, last comment.

if you wanted to add a _GUICtrlListView_GetItemChecked for each string added in the GUICtrlCreateListView?

Share this post


Link to post
Share on other sites
$LVS_EX_CHECKBOXES

Share this post


Link to post
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

  • Similar Content

    • 6401integramandj
      By 6401integramandj
      I am very new to Autoit and pretty new to scripting altogether.I have a PowerShell script that pulls owner info from folders on our file share server. There are 3 owners for every folder, Domain Admin, User setup for network scanning and the user. I am trying to copy the username only from this txt file. I have gotten as far as to being able to read the lines in the txt file but can't seem to read the columns. This is what i have so far.
      #include <File.au3>
      $file = "c:\test01.txt"
      FileOpen($file, 0)
      For $i = 5 to _FileCountLines($file)
          $line = FileReadLine($file, $i)

       msgbox(0,'','the line ' & $i & ' is ' & $line & 'and the column is')
      Next
      FileClose($file)
       
      This is the outcome.....

      This is the txt file

      I am trying to copy the ABC part without the MyDomain\. I know it's line 5 and columns 11-14 of the txt file but i can't figure out how to read it. I hope i'm explaining this correctly. 
    • PINTO1927
      By PINTO1927
      Hi Guys,
      I'm working on this project:
      $Import = GUICtrlCreateButton("Import", 15, 175, 90, 40, $WS_GROUP) $List = GUICtrlCreateListView("Name|Address|E-mail", 15, 220, 400, 363, $LVS_SORTDESCENDING) $Item1 = GUICtrlCreateListViewItem("test|test|test", $List) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Exit Exit Case $Import $Table_Import = FileOpenDialog("Import list '*.txt'", @DesktopDir & "\", "Text (*.txt)") If @error Then ContinueLoop GUICtrlSetData($Item1, $Table_Import) In the text file the fields are delimited with "|" and the values are not in the same row but one below the other.
      However in the txt file the sum of the values may change.
      Can you help me?
      Thank's
    • PINTO1927
      By PINTO1927
      Hello guys,
      I built a gui where a GUICtrlCreateListView with two columns is present.
      Through an "Import" button I would be able to import the contents of an .xls or .txt.
      Can you help me?
      Thank's
    • liagason
      By liagason
      Hello,
      I've created a script and i'd like when the user adds a new item on the ListView, that new item to be placed on top.
      GUICtrlCreateListViewItem places newly created ListViewItems right below the older ones. Is there a way to display the newest iten on top of the list view?
      Thanks a lot in advance!