Conditionally process different number of fields
Posted: Fri Aug 19, 2011 7:10 am
Have another fun CSV file to parse. It's a rather small CSV file that only has six columns in it. The problem is that the last column is not entered when "type" is 0. Any other type would column six ("comment") would be used. So an example of the records from Excel is:
Header:
Data:
So my question is there a way to conditionally process the row to handle 5 fields and then handle it another way when there is six rows?
Header:
"date","email","type","name","phone","comment"
Data:
"08/01/2011","abcdef@xyz.com","1","John Smith","555-555-1234","CEO"
"07/18/2011","abc@xyz.com","0","John Doe","123-345-6789"
"07/18/2011","abc@xyz.com","0","John Doe","123-345-6789"
So my question is there a way to conditionally process the row to handle 5 fields and then handle it another way when there is six rows?