This may have been already answered, if so, please direct me to that solution page with a link.
What I have is a file which has details of the 100 largest countries by total area (land and water surface):
('1','Russia','17,098,242(6,601,668)','Asia/Europe','Azerbaijan, Belarus, China, Estonia, Finland, Georgia, Kazakhstan, Latvia, Lithuania, Mongolia, North Korea, Norway, Poland, Ukraine')
('2','Canada','9,984,670(3,855,100)','North America','United States')
('3','United States(incl. overseas territories)','9,857,348(3,805,943)','North America','Canada, Mexico')
('4','China','9,596,961(3,705,407)','Asia','Afghanistan, Bhutan, India, Kazakhstan, Kyrgyzstan, Laos, Mongolia, Myanmar, Nepal, North Korea, Pakistan, Russia, Tajikistan, Vietnam')
('5','Brazil','8,515,770(3,287,957)','South America','Argentina, Bolivia, Colombia, France (French Guiana), Guyana, Paraguay, Peru, Suriname, Uruguay, Venezuela'),
....
....
And yes, the input file has ( & ) in the beginning and end of the line.
Any help will be really appreciated.
So far, I was trying to get this by writing:
onlyCountries = 'allcountries.txt'
print([x.split(',')[1] for x in open(onlyCountries)])
But that gives me output as:
["'Russia'", "'Canada'", "'United States(incl. overseas territories)'", "'China'", "'Brazil'"...]
Notice that extra double quotes that I get from the input file sample I gave above? I would like to get output as:
['Russia','Canada','United States','China','Brazil',....]