hey all,
Situation:
1. A file comes in a .csv format (I have no control on that part).
2.Cells need to be parsed out for DBI module load into database
3.Cell Data looks like this:
col1,col2,col3....colx
I use a while loop, and split function to assign each row a variable for the loop for processing
Problem:
1.Spliting the variables up by a comma doesnt work because some data looks like this:
cell1,"ce,ll,2",cell3,"cell,4",cell5...cellx
2. So -"ce- becomes cell2, and -ll- becomes cell3...etc. Basically the columns are shifted to the right.
Side note:
1. I did notice that all the cells that have commas (within the cell) such as cell2, and cell4, etc, have double quotes around them (due to the nature of the sftp process when I port in the file.
Question:
So how do I parse out the cells, and say "oh, and when you see double quotes, I need you to remove all the commas up until you see the next double quote". E.G. I want "ce,ll,x" to look like -cellx- (so that the split doesnt fail).
thanks for your help!!!
Situation:
1. A file comes in a .csv format (I have no control on that part).
2.Cells need to be parsed out for DBI module load into database
3.Cell Data looks like this:
col1,col2,col3....colx
I use a while loop, and split function to assign each row a variable for the loop for processing
Problem:
1.Spliting the variables up by a comma doesnt work because some data looks like this:
cell1,"ce,ll,2",cell3,"cell,4",cell5...cellx
2. So -"ce- becomes cell2, and -ll- becomes cell3...etc. Basically the columns are shifted to the right.
Side note:
1. I did notice that all the cells that have commas (within the cell) such as cell2, and cell4, etc, have double quotes around them (due to the nature of the sftp process when I port in the file.
Question:
So how do I parse out the cells, and say "oh, and when you see double quotes, I need you to remove all the commas up until you see the next double quote". E.G. I want "ce,ll,x" to look like -cellx- (so that the split doesnt fail).
thanks for your help!!!