Python Forum
Syntax error: "(" unexpected
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax error: "(" unexpected
#1
Hey all. Im working on my python code where I intend to read a particular column from the text file and then print the duplicate entries in that file. My data is in the following format:
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: 10, Freq: 937.0M, CID: 30912, LAC: 10470, MCC: 410, MNC: 1, Pwr: -39 ARFCN: 49, Freq: 944.8M, CID: 15535, LAC: 52207, MCC: 410, MNC: 3, Pwr: -28 ARFCN: 50, Freq: 954.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
Now I intend to print line 4 and 5 because values of ARFCN are 10 in both cases. Similarly, I want to print 6 and 7 because the value of CID is same for both.

I began my coding by using the uniq command

uniq -d alpha.txt

However, this doesnt give the output as long as the entire entry is similar.

I then moved forward to first read a particular column of the text file and then use this entry on that:
#! /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

f=open('alpha.txt', "r")
lines=f.readlines()
result=[]
for x in lines:
	result.append(x.split(' ')[1])
However, running thsi returns me an error:
Error:
*/\*/\*/\*/\*/\*/\*/\*/\*/\*/\*/\*/\* D A T A B A S E C O M P A R I S O N *\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/* UNIQUE BTS TOWERS ARE ./ARFCN.sh: 8: ./ARFCN.sh: Syntax error: "(" unexpected
I am using python 3.7.3 on ubuntu 18.04 LTS.
Even if this code starts working, it would output only the repetitive ARFCN or CID value and not the whole entry, where as I would require the entire list to be printed.
Reply
#2
I do not think you will be able to mix bash and python that way.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
(Jul-20-2020, 06:11 AM)menator01 Wrote: I do not think you will be able to mix bash and python that way.

okay so how do you suggest that I go about it?
Reply
#4
Tutorials here on the forum is a good place to start.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#5
(Jul-20-2020, 06:15 AM)menator01 Wrote: Tutorials here on the forum is a good place to start.

Thankyou.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax error for "root = Tk()" dlwaddel 15 1,008 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 333 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,451 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,135 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,250 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,194 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 847 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 1,777 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  Mysql Syntax error in pymysql ilknurg 4 2,288 May-18-2022, 06:50 AM
Last Post: ibreeden
  Solving equation equal to zero: How to resolve the syntax error? alexfrol86 3 1,894 Feb-21-2022, 08:58 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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