Reading variable number of columns in a file
Posted: Thu Oct 08, 2009 10:31 pm
Hi,
I have a requirement to read a file in the format as below:
A,F1,F2,F3 (Comma delimited and column A's position is fixed with 3 columns following column A). 3 is an arbitrary number. It can vary from 1 to 25.
So, I do not know the number of fields that will come in the input file.
1) How can I read such a file?
-- Assumption Runtime Column Propogation may work to read the data, but how would I know the number of columns read?
2) Second scenario is the fields will not be in the specific order. For eg. I get the file with 4 fields one time as A,F1,F2,F3 then second time we may get records as A,F3,F1,F2. In such case, how can we identify the fields.
Note: First line will have the column names, but if the number of columns are not fixed and the order is not fixed - is there a way to read these files?
The first requirement is to read this file and Pivot it with the values we receive to read the file as
A1 F1 X1
A1 F2 X2
A1 F3 X3
assuming that the file contained only one record as shown below:
A,F1,F2,F3
A1,X1,X2,X3
Any help is highly appreciated.
Thanks,
Raviraj
I have a requirement to read a file in the format as below:
A,F1,F2,F3 (Comma delimited and column A's position is fixed with 3 columns following column A). 3 is an arbitrary number. It can vary from 1 to 25.
So, I do not know the number of fields that will come in the input file.
1) How can I read such a file?
-- Assumption Runtime Column Propogation may work to read the data, but how would I know the number of columns read?
2) Second scenario is the fields will not be in the specific order. For eg. I get the file with 4 fields one time as A,F1,F2,F3 then second time we may get records as A,F3,F1,F2. In such case, how can we identify the fields.
Note: First line will have the column names, but if the number of columns are not fixed and the order is not fixed - is there a way to read these files?
The first requirement is to read this file and Pivot it with the values we receive to read the file as
A1 F1 X1
A1 F2 X2
A1 F3 X3
assuming that the file contained only one record as shown below:
A,F1,F2,F3
A1,X1,X2,X3
Any help is highly appreciated.
Thanks,
Raviraj