Jump to content

Finding combinations and remove line


Read
 Share

Recommended Posts

I have very BIG .txt file and PHP script not enough - very slow.

Welll....

I have the combinations in the document (.txt)

01 02 07 14 32 37

01 02 07 14 32 36

01 02 07 14 32 35

01 03 05 06 07 44

01 03 05 06 07 43

01 03 05 06 07 42

01 04 05 06 07 16

PHP:

$find= array(array(01, 02, 14, 37), array(01, 03, 06, 07, 43));

Script searches for the document and if found numbers (array) then delete/remove this combination - line.

Example:

Script searching and found: 01 02 07 14 32 37 and 01 03 05 06 07 43

01 02 07 14 32 37 (DELETE)

01 02 07 14 32 36

01 02 07 14 32 35

01 03 05 06 07 44

01 03 05 06 07 43 (DELETE)

01 03 05 06 07 42

01 04 05 06 07 16

How to make it?

ENG bad :)

Thank you

Edited by Read
Link to comment
Share on other sites

  • Replies 91
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hard my English!!!

Combinations is 6 numbers

01 02 07 14 32 37

01 02 07 14 32 36

Array is 5

$find= array(array(01, 02, 03, 04, 05));

Edit:

Are the numbers always 2 chars long? You mean "array"? Then 900

Edited by Read
Link to comment
Share on other sites

@Read

This is how I understand it:

Every line of the file has 6 numbers. The array has 5 numbers. Every line that contains all of the 5 numbers should be deleted.

I'm not sure if "Then 900" means that the numbers can be 3 characters ("900") long.

Is this correct?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Water!

Yes! Every line of the file has 6 numbers. The array has 5 numbers. Every line that contains all of the 5 numbers should be deleted.

I can be defined, 20 or 40 or 150 but a total of 900.

My PHP script I used Array. AutoIT- don't know.

Link to comment
Share on other sites

What do you mean by "I can be defined, 20 or 40 or 150 but a total of 900."?

Is this the number of records in the file or the number of entries in the array?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Read,

Yes, I understand (and am very patient).

Like: .txt file format = nn nn nn nn nn nn (per line - line is terminated by @crlf)

where: nn = any number between 1 and 99

each line always contains 6 numbers and numbers do NOT repeat within a single line

logic: get number string to delete

open file

find number string in file and delete

close file

Something similar to the above.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Try this:

#include <array.au3>
$sComb = StringReplace(StringStripCR(FileRead(@ScriptDir & "Combi.txt")), @LF, "|")  & "|"

$aComb = StringSplit($sComb, "|", 2)

$sNd1 = "01 02 07 14 32 37"
$sNd2 = "01 03 05 06 07 43"

_ArrayDisplay($aComb)
SearchAndDestroy($aComb, $sNd1)
SearchAndDestroy($aComb, $sNd2)

_ArrayDisplay($aComb)
$hFile = FileOpen(@ScriptDir & "Combi-New.txt", 2)
FileWrite($hFile, _ArrayToString($aComb, @LF))
FileClose($hFile)

Func SearchAndDestroy(ByRef $array, $search)
    If Not IsArray($array) Then Return SetError(1, 0, 0)
    Local $ai = _ArrayFindAll($array, $search)
    If @error Then Return SetError(2, @error, 0)
    Local $i
    For $i = 0 To UBound($ai) - 1
        _ArrayDelete($array, $ai[$i] - $i)
    Next
    Return 1
EndFunc

Combi.txt is the file with the combinations.

imho 200 mb is not really big.

Br,

UEZ

Edit: changed the code -> removed StringRegEx and added _ArrayFindAll() to catch all search strings

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ

200 mb is not really big

It's big for PHP :)

Code.

Something is wrong.

My .txt file and comb..

01 02 07 14 32 37

01 02 07 14 32 36

01 02 07 14 32 35

01 03 05 06 07 44

01 03 05 06 07 43

01 03 05 06 07 42

01 04 05 06 07 16

and array:

$sNd1 = "01 02 14 32 37"

Right now must delete 01 02 07 14 32 37 not 01 04 05 06 07 16

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...