+ 4
Separating values with "comma" as a delimiter ?
I'm working with a project, in this there will be variable holding any data types just separated with a comma. I need to separate all these things and also need to define which type it is. For e.g: data="Hello, Hey",123,10.04 I used split() function to separate, but it separates the comma even within the string "Hello,Hey" I don't need like this, all i need is, just to separate the values by commas but not by the commas inside the string. I killed my brain, but it is still a problem for me.
15 Respostas
+ 4
What about this?
https://code.sololearn.com/cVdQI6g3xG89/?ref=app
+ 4
And here is my Need !!
https://code.sololearn.com/cY6rwq9f5KB1/?ref=app
Got this from Stack Overflow
+ 3
Sorry Hemath Kumar I cant seem to figure it out
But i think this should help:
https://code.sololearn.com/cY6rwq9f5KB1/?ref=app
+ 3
thanks for all ! finally got the solution !!
All of your solutions were almost matched my need !!
But I got the complete result in "re module"
+ 2
+ 1
Okay Agent just leave.... some others will help
+ 1
try putting this in front of the coma \
+ 1
davy hermans let me elaborate my whole problem....
actually my project is a lexer, which will tokens my input.
It need to separate the values and specify which data type it is..!!
There's no matter, if my print status has only one value, but if there are many, which are separated by comma, I need to make the tokens for them too by splitting it up....
so now, as in this point of view,
my "data" variable is not a tuple, it is a string
it actually looks like,
data = ' "Hey, Hello",123 '
now I need to separate this!!
+ 1
Hemath Kumar are hey and hello separate or together?
+ 1
no, they are single string,
like print "Hello, Hey"
+ 1
or "Hello, Longtie"
+ 1
I think this is exactly what u want
Please inform me if it was exactly what u wante or you need some more changes.
https://code.sololearn.com/c7oW2j7yp1Mf/?ref=app
0
if data is a tuple (as it looks to be) you could use:
for i in data:
print(i)
or is it a string holding these elements?
0
LONGTIE actually your answer is good enough,
but my problem is above, just read it out and give me the solution pls