Syntax error: "(" unexpected - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Syntax error: "(" unexpected (/thread-28457.html) |
Syntax error: "(" unexpected - buttercup - Jul-20-2020 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: 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: 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. RE: Syntax error: "(" unexpected - menator01 - Jul-20-2020 I do not think you will be able to mix bash and python that way. RE: Syntax error: "(" unexpected - buttercup - Jul-20-2020 (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? RE: Syntax error: "(" unexpected - menator01 - Jul-20-2020 Tutorials here on the forum is a good place to start. RE: Syntax error: "(" unexpected - buttercup - Jul-20-2020 (Jul-20-2020, 06:15 AM)menator01 Wrote: Tutorials here on the forum is a good place to start. Thankyou. |