Answer the question
In order to leave comments, you need to log in
How to split strings by commas when there are commas in some values that do not need to be split?
there is a movies.csv file that
looks like this:
movieId,title,genres
1,Toy Story (1995),Adventure|Animation|Children|Comedy|Fantasy
2,Jumanji (1995),Adventure|Children|Fantasy
3,"American President, The (1995)",Comedy|Drama|Romance
4,Waiting to Exhale (1995),Comedy|Drama|Romance
5,Father of the Bride Part II (1995),Comedy
6,"City of Lost Children, The (Cité des enfants perdus, La) (1995)",Adventure|Drama|Fantasy|Mystery|Sci-Fi
7,"Postman, The (Postino, Il) (1994)",Comedy|Drama|Romance
8,"Indian in the Cupboard, The (1995)",Adventure|Children|Fantasy
9,Tom and Huck (1995),Adventure|Children
...
running the program should look like this:
cat movies.csv | python3 program.py
i do splits like this
for line in sys.stdin:
list = line.split(',')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question