[try Beta version]
Not logged in

 
Specific reading of CSV file

Dec 12, 2016 at 6:25am
Hello!
I have a csv file that has the following strings on it:
Full Name, Telephone Number, Email Address.

This file will contain incorrect information - for example a telephone number such as 622ABC456DD6555.
I have to make a program that will read the input, but eliminate unnecessary data, or if all the date is corrupted- state so.

Full name is first and last name of a person, which can only contain letters.
Telephone number can be only numbers, but can contain parentheses in this format
(###)### ####, or be written as ###-###-####.

Email address can be a mix, but can only have one @ symbol.

For email, this was easy to do, but what would be an elegant way for the rest?
For example, I can make a loop that checks every character in those strings.
But for telephone, for example, I dont want to make a check that asks whether the input is equal to 1, then to 2, then to 3... all the way to 9.

Is there any elegant way of doing this?
Dec 12, 2016 at 8:53am
Dec 12, 2016 at 8:59am
To validate the phone number you can use regular expressions.
http://www.cplusplus.com/reference/regex/
Dec 12, 2016 at 2:36pm
Thank you both!
Topic archived. No new replies allowed.