Jump to content

Remove array elements where doesn't contain....


Recommended Posts

  • Moderators

rony2006,

What have you tried that has not worked?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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

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 by mikell
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...