Question on List processing
subhabangalore at gmail.com
subhabangalore at gmail.com
Tue Apr 26 11:38:27 EDT 2016
On Monday, April 25, 2016 at 10:07:13 PM UTC+5:30, Steven D'Aprano wrote:
> On Tue, 26 Apr 2016 12:56 am, wrote:
>
> > Dear Group,
> >
> > I have a list of tuples, as follows,
> >
> > list1=[u"('koteeswaram/BHPERSN engaged/NA himself/NA in/NA various/NA
> [... 17 more lines of data ...]
>
> Hi Subhabrata, and thanks for the question.
>
> Please remember that we are offering help for free, in our own time. If you
> want help from us, you should help us to help you.
>
> It is very unlikely that many people will spend the time to study your data
> in close enough detail to understand your requirements. Please give a
> *simplified* example. Instead of 17 lines of repetitive data, use a "toy"
> example that matches the format but without all the complicated details.
> And format it so that it is easy to read:
>
> input = [u"('a/b/ ','A')",
> u"('z/x/ ','B')",
> u"('b/d/ ','C')",
> ]
>
> output = ????
>
>
>
> > I tried to make it as follows,
> [...]
> > but not helping.
>
> What do you mean, "not helping"? What happens when you try?
>
> Please show a *simple* example, with no more than four or five lines of
> *short, easy to read* text.
>
> Remember, we are giving you advice and consulting for free. We are not paid
> to do this. If your questions are too difficult, boring, tedious, or
> unpleasant, we will just ignore them, so please help us to help you by
> simplifying them as much as possible.
>
> Thank you.
>
>
>
>
> --
> Steven
Dear Steven,
Thank you for your kind suggestion.
I will keep it in mind.
I am trying to send you a revised example.
list1=[u"('koteeswaram/BHPERSN engaged/NA ','class1')", u"('koteeswaram/BHPERSN is/NA ','class1')"]
[('koteeswaram/BHPERSN engaged/NA ','class1'),
('koteeswaram/BHPERSN is/NA ','class1')]
I tried to make it as follows,
list2=[]
for i in list1:
a1=unicodedata.normalize('NFKD', i).encode('ascii','ignore')
a2=a1.replace('"',"")
list2.append(a2)
and,
for i in list1:
a3=i[1:-1]
list2.append(a3)
but I am not getting desired output.
If any one may kindly suggest how may I approach it?
Regards,
Subhabrata
More information about the Python-list
mailing list