Author Topic: I have a blocklist for my pihole and need to remove some lines  (Read 2434 times)

0 Members and 1 Guest are viewing this topic.

Offline smokingwheels

  • Newbie
  • Posts: 6
    • View Profile
I have a blocklist for my pihole and need to remove some lines
« on: February 18, 2021, 07:43:59 am »
I open my list then compare each line with a array of urls from my whitelist.
The problem is the longer my whitelist is the longer it takes to complete the task.

Should I try 1 url at a time then replace the list for each url?
This means I would need to read and write 200 mb of data for each url.

Currently I have to compare each line to 80 urls that I would like whitelisted or removed from my blocklist
The list is over 6 million lines of text.

Blocklist link
 https://t.co/vRyCbbpcth?amp=1

Marked as best answer by smokingwheels on March 04, 2021, 06:29:46 pm

FellippeHeitor

  • Guest
Re: I have a blocklist for my pihole and need to remove some lines
« Reply #1 on: February 18, 2021, 08:03:09 am »
Hope the idea helps. Adapt as required:

Code: QB64: [Select]
  1. open "crazy long file.txt" for binary as #1
  2. wholefile$ = space$(lof(1))
  3. get #1, 1, wholefile$
  4.  
  5. for i=1 to 80
  6.     if instr(wholefile$, arrayOfUrls$(i)) > 0 then
  7.         'this url is in the file, do something with it
  8.     end if
  9.  

Offline smokingwheels

  • Newbie
  • Posts: 6
    • View Profile
Re: I have a blocklist for my pihole and need to remove some lines
« Reply #2 on: February 18, 2021, 09:56:29 am »
ok will give it a go soon. Thank you

Offline smokingwheels

  • Newbie
  • Posts: 6
    • View Profile
Re: I have a blocklist for my pihole and need to remove some lines
« Reply #3 on: February 18, 2021, 10:48:26 am »
I tried to run an old program but it seems to only work with 2 files open.
I have not converted it yet

Code: QB64: [Select]
  1. Rem Updated 7-1-2018
  2. Rem runs at 20 kHz
  3. Rem 30-1-2018
  4. Rem runs at 18.8 kHz
  5. Rem About 7 meg after crunchmaster.sh
  6. Rem found a space #...AND null string in the same day.
  7. Rem fixed some errors 4 NOV 17
  8. On Timer(1) GoSub health
  9.  
  10. Open "/home/john/Downloads/qb64/pi-hole/Master/w10" For Input As #4
  11.  
  12. Print "ghjkl"
  13. Rem array
  14. Dim whitelist$(2000)
  15.  
  16.     i = i + 1
  17.  
  18.     Print "1234"
  19.  
  20.     Line Input #4, a$
  21.     Print a$
  22.     whitelist$(i) = a$
  23.     Print Len(whitelist$(i))
  24.  
  25.  
  26. Open "/home/john/Downloads/qb64/pi-hole/Master/list5" For Input As #1
  27. Print "file 1 open"
  28. Open "/home/john/Downloads/qb64/pi-hole/Master/piholelist" For Output As #2
  29.  
  30.  
  31.  
  32. Rem chomp 2 try to remove null from gravity.
  33.  
  34. one = 1
  35. stack = 578
  36.     Line Input #1, a$
  37.     a = a + 1
  38.  
  39.     For i = 1 To stack
  40.  
  41.         wline = Len(whitelist$(i))
  42.         Print whitelist$(i)
  43.         'PRINT RIGHT$(a$, 10), whitelistline
  44.  
  45.         If Right$(a$, wline) = Right$(whitelist$(i), wline) Then GoTo skipoutput
  46.  
  47.     Next
  48.     lline = Len(a$)
  49.     'IF lline > 71 THEN GOTO skipoutput
  50.     Print #2, a$
  51.     skipoutput:
  52.     Hz = Hz + one
  53. Close #1: Close #2: Close #3: Close #4
  54. Print a, b
  55. Print "Thankyou Happy Hunting..."
  56.  
  57. health:
  58. Print Hz, a, b
  59. Hz = 0
  60.  
  61.