I have a fixed length .txt file. Values in the file correspond to columns in a db table.
ex file row is something like:
India 3455 78787 89898
table has columns something like:
column_name length startPosn EndPosn
country 6 1 6
ID 6 7 13
so you see that the spaces are actually part of the values, its not delimited.
what i have to do it insert each value and create 1 row in the db(assuming there's only 1 row in the txt file right now).
Problem is that I will want to give the user some flexibility that he can change column lengths in future. As a result i was thinking of create a .dat file with 'column_name,length,start-posn' mentioned in it for each column. Then i would read this .dat file first. accordingly get the startPosn-length for each column and get the substrings from the original .txt file(which i would have read in a string) and create an insert query.
Just wondering if anyone can suggest a more efficient way to do this or any issues I can get in this approach?