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

#10 ·  Posted

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

#11 ·  Posted

 

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

#12 ·  Posted

$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

    • PINTO1927
      Add .txt to GUICtrlCreateListView
      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
      GUICtrlCreateListView Excel
      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
      GUICtrlCreateListViewItem newest item on top. how to?
      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!
    • ur
      To skip code if it is a library
      By ur
      Is there any way to skip the execution of a particular block of code like any condition or expression, if the au3 file is included as library.?
      Like, in my code I wrote all the functionality as functions and called them in 4 lines.
      Now I have another requirement where I need to use the same code but different.So I am importing this code so that I can use these functions.
      But the code block which is outside the functions (main code) is being executed when I import the au3 file.Is there any condition to check whether the file is running directly or included in another au3 file as library, so that I can keep the same here.
       
      Please suggest if any ideas.