Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why when opening a txt file, you loose the ',' character

–1 vote
asked Apr 17, 2025 by Jerry Wanger (110 points)
If the file says Jerry, David, Joy

When you read it in it translates it to

Jerry David Joy

This is related to working with csv files by renaming it from csv to txt

A work around is once it is opened, cut and paste the file with the ",' characters

1 Answer

0 votes
answered Apr 18, 2025 by Peter Minarik (101,420 points)
CSV means comma-separated values. So your file containing "Jerry, David, Joy" means for a CSV file that you have 3 values there "Jerry", "David" and "Joy". The comma is not part of the values, it is the separator.

If you want to have the commas to be part of the value, you can change how you parse your file and instead of a comma, you could use a different separator, e.g. semicolon (;) or TAB, etc.

I hope this helps.

Good luck!
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...