Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

File need to be read in different formats( Tab formatted, commas separated)

Neslinn
Participant
0 Kudos

Hi All,

I am reading an input text file which can be in any of the format like tab formatted, commas separated or fixed format. How can i write a code to make it work for all these file format other than writing separately for the above three cases. Kindly suggest.

Thanks,

Neslin.

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

As far as seperators are concerned you may read entire file to stirng table, then identify separator (i.e. if you find tab mark, you assume it is tab separated; if you find ";" mark you assume this is a column separator). Use SEARCH or FIND statement and then (after having the separator) loop at string table and split each entry at this separator. If none of the above was find (no separator or fixed one) split according to given fixed format.

2 REPLIES 2

MarcinPciak
Active Contributor
0 Kudos

As far as seperators are concerned you may read entire file to stirng table, then identify separator (i.e. if you find tab mark, you assume it is tab separated; if you find ";" mark you assume this is a column separator). Use SEARCH or FIND statement and then (after having the separator) loop at string table and split each entry at this separator. If none of the above was find (no separator or fixed one) split according to given fixed format.

0 Kudos

Thanks Marcin.

That was helpful.

Neslin.