Hello,

I have a huge file with the following kind of lines:

A,B,C 1,2,3
D,E 4,5

What is efficient way to split and get the following output using python?

A 1
B 1
C 1
A 2
B 2
C 2
A 3
B 3
C 3
D 4
D 5
E 4
E 5

Any help appreciated.

Thank you
S

Recommended Answers

All 2 Replies

Can you explain the details of the file you want to split?

if each line is like this:
"A,B,C 1,2,3",
you can do str.split(" ")
and you'll get:
["A,B,C","1,2,3"]
and do another str.split(",")
and you'll have nice organized lists
and go from there

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.