rony2006 Posted October 9, 2017 Share Posted October 9, 2017 Hello, I have a 2d array and I want to remove all array elements that doesn't contain "csv" substring inside. How can I do this please? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 9, 2017 Moderators Share Posted October 9, 2017 rony2006, What have you tried 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 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 Link to comment Share on other sites More sharing options...
rony2006 Posted October 9, 2017 Author Share Posted October 9, 2017 I tried this code: Local $aArray[5][5] = [[0, 1, 2, 1, 0], _ [4, 5, 5, 4, 2], _ [4, 1, 3, 1, 3], _ [0, 3, 2, 1, 0], _ [1, 5, 5, 4, 1]] _ArrayDisplay($aArray, "2D array") Local $aResult = _ArrayFindAll($aArray, 0, Default, Default, Default, Default, 4) _ArrayDisplay($aResult, "Found in Column 4") Modified in Local $aResult = _ArrayFindAll($aArray, 0, Default, Default, Default, "csv", 4) $aResult cotains a lot of urls to .csv files. Link to comment Share on other sites More sharing options...
mikell Posted October 9, 2017 Share Posted October 9, 2017 So what ? _ArrayFindAll returns an array of indexes. Just use this array as $vRange param in _ArrayDelete Link to comment Share on other sites More sharing options...
rony2006 Posted October 9, 2017 Author Share Posted October 9, 2017 _ArrayFindAll doesn't return me any result. I don't understand why. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 9, 2017 Moderators Share Posted October 9, 2017 rony2006, Then give us an actual example of the data in your array and the code you are using to find whatever it is you are looking for. Otherwise how do you expect us to be able to help you? M23 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 Link to comment Share on other sites More sharing options...
rony2006 Posted October 9, 2017 Author Share Posted October 9, 2017 Hello, $oWorkbook = "C:\Users\Marian\Downloads\Rapoarte Electro\"&$aFileList[1] $sFileOpenDialog = $oWorkbook ; Create application object and open an example workbook Local $oExcel = _Excel_Open(False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileOpenDialog) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf ; ***************************************************************************** ; Read the formulas of a cell range on sheet 2 of the specified workbook ; ***************************************************************************** Local $aResult = _Excel_RangeRead($oWorkbook, Default,Default, 2) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Data successfully read." & @CRLF & "Please click 'OK' to display the formulas of cells A1:C1 of sheet 2.") ;_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 2 - Cells A1:C1 of sheet 2") With this code I make a csv file to 2d array. The csv file looks like the one attached. Then I want to upload to a mysql database all links (only one column) that contains links to .csv files. Now I upload all data to mysql and then I delete all that doesn't contain %csv%. $sMySqlStatement = "DELETE FROM linklist WHERE link NOT LIKE '%csv%';" If Not _EzMySql_Exec($sMySqlStatement) Then _GUICtrlEdit_AppendText($input1, @CRLF &$sMySqlStatement) MsgBox(0, "Error Creating Database Table", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf www.cenace.gob.mx_9th_Oct_2017 (6).csv Link to comment Share on other sites More sharing options...
mikell Posted October 9, 2017 Share Posted October 9, 2017 (edited) A nice way would be to extract first the wanted links to a new (temp) .csv before uploading #Include <Array.au3> #include <File.au3> $s = FileRead("www.cenace.gob.mx_9th_Oct_2017 (6).csv") $res = StringRegExp($s, '(?m)^"([^"]+csv)' , 3) _ArrayDisplay($res) _FileWriteFromArray(@scriptdir & "\new.csv", $res) Edit This keeps the quotes around the links $res = StringRegExp($s, '(?m)^("[^"]+csv")' , 3) Edited October 9, 2017 by mikell junkew 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now