REPLACE nth Column of CSV file based on condition
Posted: Tue Feb 25, 2014 5:20 pm
Hi ,
I have a requirement to replace nth column of a CSV file based on condition . I did tried using parse option but i am not having idea to include the condition and replace the value
My Input looks like below
F19A,00001243,0165,20120320,1,245.00,,,,,,,0,0,,0,26,0,0,0,0,0,,1646,N,N
F19A,00001243,0165,20120321,1,245.00,,,,,,,0,0,,0,26,0,0,0,0,0,,,N,N
F19A,00001243,0200,20120320,1,245.00,,,,,,,0,0,,0,26,0,0,0,0,0,,1646,N,N
The value 1646 present in the 24th column need to be changed based on condition 0165 [value in 3rd column]
For e.g if the input file contains 0165 then value in 24th column need to be changed as 1900 remaining columns unchanged . If the input file contains 0200 then value in 24th column need to be changed as 1000 remaining columns unchanged , similarly for some more codes.If an match is not found nothing need to be done for that record.
can any help in letting me know how to achieve this ?
I have a requirement to replace nth column of a CSV file based on condition . I did tried using parse option but i am not having idea to include the condition and replace the value
My Input looks like below
F19A,00001243,0165,20120320,1,245.00,,,,,,,0,0,,0,26,0,0,0,0,0,,1646,N,N
F19A,00001243,0165,20120321,1,245.00,,,,,,,0,0,,0,26,0,0,0,0,0,,,N,N
F19A,00001243,0200,20120320,1,245.00,,,,,,,0,0,,0,26,0,0,0,0,0,,1646,N,N
The value 1646 present in the 24th column need to be changed based on condition 0165 [value in 3rd column]
For e.g if the input file contains 0165 then value in 24th column need to be changed as 1900 remaining columns unchanged . If the input file contains 0200 then value in 24th column need to be changed as 1000 remaining columns unchanged , similarly for some more codes.If an match is not found nothing need to be done for that record.
can any help in letting me know how to achieve this ?