0

When I am retrieving a record from DB getting the record as below

('("2014-02-21 07:10:40",ManualNo,184,vsp,AP10123456,aaaaa,Coconut-Na,5,10)',) 

and I need to get the data as tuple like:

("2014-02-21 07:10:40",ManualNo,184,vsp,AP10123456,aaaaa,Coconut-Na,5,10)

without using split function and then want to get the individual values from it.

like

record[0] = 2014-02-21 07:10:40
record[1] = ManualNo 

and so on...

2
  • Why oh why don't you use split? Commented Mar 7, 2014 at 10:08
  • How are you getting that record from the DB - could you show the code for that? I get a feeling this might be a wild goose chase... Commented Mar 7, 2014 at 10:09

1 Answer 1

1

You can simply split the string over the comma:

data = ('("2014-02-21 07:10:40",ManualNo,184,vsp,AP10123456,aaaaa,Coconut-Na,5,10)',)
record = data[0].lstrip('(').rstrip(')').split(',')
Sign up to request clarification or add additional context in comments.

1 Comment

We know how the retrieve by splitting the string but what I need is to convert the String into tuple. If we have comma in between the value it will not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.