slvtn666 0 Posted July 3, 2018 Hello! Im new to autoit. I have .csv file with 8 coloumns and over 7-9k rows with tab delimeter. I split this file into 2D array using _FileReadToArray($file, $retArray, '', @TAB). In second column of .csv file i have digit based string, this strings is not unique: for example: 57814510303 57814510303 57814510303 57954184645 57986498899 57986498899 I want to get unique values in separate array, now im getting result using following code: Local $retArray _FileReadToArray($file, $retArray, '', @TAB) Local $idArray[UBound($retArray) - 1] For $i = 1 To UBound($retArray) - 1 _ArrayPush($idArray, $retArray[$i][1]) Next $uniqueIdArray = _ArrayUnique($idArray, "", "", "", 0, "") The script part with For $i = 1 To UBound($retArray) - 1 _ArrayPush($korobIdArray, $retArray[$i][1]) Next takes over 52 seconds for 7500 entries. May be i should use another function instead _ArrayAdd to make it faster? Sorry for my bad english, and thank you for your replies Share this post Link to post Share on other sites
LarsJ 680 Posted July 3, 2018 Replace your _ArrayPush loop with this: For $i = 1 To UBound($retArray) - 1 $korobIdArray[$i] = $retArray[$i][1] Next 1 Compiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeWindows Explorer: Automating and examples, Implementing right pane, Implementing address barShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsControl related: Hot-Track Enabled Toolbar Menu, Simulating a modeless Choose Color Dialog, Colors and fonts in TreeViewsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Share this post Link to post Share on other sites
slvtn666 0 Posted July 3, 2018 3 minutes ago, LarsJ said: Replace your _ArrayPush loop with this: For $i = 1 To UBound($retArray) - 1 $korobIdArray[$i] = $retArray[$i][1] Next Wow, thanks, now it takes miliseconds... its very obvious, why did not I think of it myself. Thank you, i really appreciate your help Share this post Link to post Share on other sites
Vincor 4 Posted July 3, 2018 And now, just for the fun of it, a solution using Regular Expressions: #include <StringConstants.au3> #include <Array.au3> Local $korobIdArray = StringRegExp(FileRead("file.tsv"),"(?m)^[^\t]\t(.*)$",$STR_REGEXPARRAYGLOBALMATCH) Local $uniqueIdArray = _ArrayUnique($korobIdArray, 0, 0, 0, 0) Share this post Link to post Share on other sites
Melba23 2,925 Posted July 3, 2018 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Share this post Link to post Share on other sites