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
#2
and your python-related question is....?
so far there is no python code or question in your threads.
Also, there is similar thread from another user. Is this some sort of homework/assignment?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Jul-20-2020, 06:53 AM)buran Wrote: and your python-related question is....?
so far there is no python code or question in your threads.

Im sorry. But I intend to make a new file minus the not required entry using python and was wondering if you could lend me some help with that.
Reply
#4
(Jul-20-2020, 06:56 AM)monstrup Wrote: But I intend to make a new file minus the not required entry using python and was wondering if you could lend me some help with that.
great! show your PYTHON code, in python tags. If you get any traceback, show it in full, in error tags. Ask specific questions. If you don't know where to start - look at our tutorials about working with files.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Jul-20-2020, 06:56 AM)monstrup Wrote:
(Jul-20-2020, 06:53 AM)buran Wrote: and your python-related question is....?
so far there is no python code or question in your threads.

Im sorry. But I intend to make a new file minus the not required entry using python and was wondering if you could lend me some help with that.

Also its not for an assignment. Its just a bunch of university students working on a leisure project.
Reply
#6
Do you really even need Python for this? Wouldn't say sed be good for removing lines?
Reply


Forum Jump:

User Panel Messages

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