Click here to Skip to main content
15,888,303 members
Please Sign up or sign in to vote.
2.50/5 (3 votes)
See more:
I want to create a C++ class that will convert a pipe-delimited text file to csv. I new to OOP.

Thanks!
Posted
Comments
Sergey Alexandrovich Kryukov 7-Dec-13 20:22pm    
First of all, why? What have you tried so far?
What is "pipe-delimited"? If you new to OOP, first learn it, using manuals and documentation.
—SA
CPallini 8-Dec-13 3:29am    
You don't even need OOP for such a trivial task.

1 solution

Technically, a file with elements delimited by '|' characters is a CSV file - the name covers a multitude of separators and most CSV readers allow you to specify the separator character.
http://en.wikipedia.org/wiki/Comma-separated_values[^]

It would be trivial to do a "simple" conversion of your data from '|' to ',' - just read it in, scan for '|' and splat them with a ',' - it doesn't require any inserts or deletes so there is no change in the file length. However, it may be that you need to check the content as well - if the fields between '|' contain ',' and are not surrounded by '"' characters then you will need to replace those as well.

But in most case, you don't need to make any changes at all to read the '|' separated file.
 
Share this answer
 
Comments
CPallini 8-Dec-13 3:28am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900