Hi,
I have a text file having size about 2 GB. The text file format is like:
Numeric value[space]AlphaNumeric values
Numeric value[space]AlphaNumeric values
Numeric value[space]AlphaNumeric values
For example consider following chunk of actual data:
52 SANZP3118.00Q31 26T070533N16CEP XT
96 SANZP3118.00Q72 94T070534N17CEP
100 SBHPP3200.00Q16 000T070534N18CE PXT
150 SBHPP3200.00Q10 00T070534N19CEP
153 SBHPP3200.00Q50 00070534N20CEP
159 SBHPP3200.00Q30 00070534N21CEP
168 SBHPP3200.00Q11 1000T070534N22C EP
168 SLHGP375.00Q400 0T070534N26CEP
210 SBHPP3200.0Q000 T070534N23CEP
569 SLHGP375.00Q230 00T070534N24CEP
1000 SLHGP375.00Q162 000T070534N25CE P
1010 SLHGP375.00Q400 0T070534N26CEP
Now what I want to is to find a specific numeric value at the beginning of
the line. For example in the above few lines the numeric values are
52,96,100,150,1 53,159,168,210, 569,1000,1010 (these values are always
sorted). Suppose I have to search 168. Since the values are sorted I can use
the binary search technique to search a specific numeric value. But for that
I will have to read all the numeric values sequentially into some array in
memory. The other way is sequential search i.e to read line by line and
fetch the numeric value before [space] and compare it with required one.
What is the best possible way to perform searching in the above mentioned
file format.
Thanks in anticipation,
Regards,
Ahmad Jalil Qarshi
I have a text file having size about 2 GB. The text file format is like:
Numeric value[space]AlphaNumeric values
Numeric value[space]AlphaNumeric values
Numeric value[space]AlphaNumeric values
For example consider following chunk of actual data:
52 SANZP3118.00Q31 26T070533N16CEP XT
96 SANZP3118.00Q72 94T070534N17CEP
100 SBHPP3200.00Q16 000T070534N18CE PXT
150 SBHPP3200.00Q10 00T070534N19CEP
153 SBHPP3200.00Q50 00070534N20CEP
159 SBHPP3200.00Q30 00070534N21CEP
168 SBHPP3200.00Q11 1000T070534N22C EP
168 SLHGP375.00Q400 0T070534N26CEP
210 SBHPP3200.0Q000 T070534N23CEP
569 SLHGP375.00Q230 00T070534N24CEP
1000 SLHGP375.00Q162 000T070534N25CE P
1010 SLHGP375.00Q400 0T070534N26CEP
Now what I want to is to find a specific numeric value at the beginning of
the line. For example in the above few lines the numeric values are
52,96,100,150,1 53,159,168,210, 569,1000,1010 (these values are always
sorted). Suppose I have to search 168. Since the values are sorted I can use
the binary search technique to search a specific numeric value. But for that
I will have to read all the numeric values sequentially into some array in
memory. The other way is sequential search i.e to read line by line and
fetch the numeric value before [space] and compare it with required one.
What is the best possible way to perform searching in the above mentioned
file format.
Thanks in anticipation,
Regards,
Ahmad Jalil Qarshi
Comment