Python Forum
How to delete a particular entry from a database.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to delete a particular entry from a database.
#1
Hey all.
Im working on a code where I have a text file
Output:
ARFCN: 1004, Freq: 931.0M, CID: 36231, LAC: 7713, MCC: 410, MNC: 4, Pwr: -35 ARFCN: 1008, Freq: 931.8M, CID: 47103, LAC: 7713, MCC: 410, MNC: 4, Pwr: -48 ARFCN: 6, Freq: 936.2M, CID: 10096, LAC: 10470, MCC: 410, MNC: 1, Pwr: -28 ARFCN: 10, Freq: 937.0M, CID: 30911, LAC: 10470, MCC: 410, MNC: 1, Pwr: -39 ARFCN: 49, Freq: 944.8M, CID: 15535, LAC: 52207, MCC: 410, MNC: 3, Pwr: -28 ARFCN: 66, Freq: 948.2M, CID: 10001, LAC: 470, MCC: 410, MNC: 6, Pwr: -39 ARFCN: 100, Freq: 955.0M, CID: 667, LAC: 1007, MCC: 410, MNC: 3, Pwr: -30
I have another text file containing a larger number of registered towers. When I compare the above given data with the database text file using the following code:
#! /bin/sh
clear
echo "                      */\*/\*/\*/\*/\*/\*/\*/\*/\*/\*/\*/\* "
echo "                      D A T A B A S E  C O M P A R I S O N  "
echo "                      *\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/* "
echo UNIQUE BTS TOWERS ARE


gawk 'BEGIN{FS=OFS=", "} NR==FNR{Database[$1 $2 $3 $4 $5 $6]; next}
        $1~/ARFCN: / && !($1 $2 $3 $4 $5 $6 in Database)' Database.txt 		alpha.txt | tee beta.txt

echo "These BTS are not available in the database. "
notify-send "SCANNED!"
echo DONE!
I get the alleged fake tower in a new text file called beta.txt. In order to perform further tests, I need to compare certain parameters with the original alpha.txt file.

My question, basically, is to seek guidance as to how I can remove the entry stored in beta.txt from the file alpha.txt. In other words, I want to automatically create a new file having data of alpha.txt minus the data in beta.txt.
Im sorry if my question is crude or very basic. But I am new to python and would greatly appreciate any guidance
Regards.
Reply


Messages In This Thread
How to delete a particular entry from a database. - by monstrup - Jul-20-2020, 06:47 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020