Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve data from text files for sorting

Status
Not open for further replies.

cutesy

Programmer
Feb 16, 2002
4
SG
Hi. I am trying to process very large text files whereby the data are stored in columns and rows (like a table) Visual Basic 6.0.

The text file looks something like this:

* LRU1 LRU2 LRU3 LRU4 LRU5 LRU6 LRU7 ......Dummy5
Bn1_Failures 0.2 0.1 0 0.3 0.4 0.6 0.9 0.1 0.9
.
Bn9_Failures 0.4 0.5 0 0.1 0.8 0.6 0.7 0.2 1.9
--------------------------------------------------
Bn1_SparesFill 100% 80% 70% 60% 50% 40% 30% 10%
.
Bn9_SparesFill 50% 40% 30% 10% 80% 70% 40% 60%

LRU1, LRU2, etc are the line items whereas Bn1_Failure to Bn9_Failure, etc are the criterias / properties belonging to each line items

Each group of criteria is segregated by a -

The first group may contain criteria of Bn1_Failure all the way to Bn9_Failures, second group may contain criteria of Bn1_SparesFill to Bn9_SparesFill, Bn1_SparesWait to Bn9_Spareswait, Bn1_DownBySparesP1 to Bn1_DownBySparesP3 ... Bn9_DownBySparesP3, etc. The number of criterias are also unfixed too.

The number of line items are not fixed whereby there can be any number

I need to populate the criterias i.e. Bn1_Failures to Bn9_Failure,etc (i.e. all the items in the first column) into a combo box. Upon choosing a criteria from the combo box i.e. Bn1_SparesFill from the list, it will retrieve all the items pertaining to Bn1_SparesFill,Bn1_SparesWait and Bn1Down_bySpare_P1,Bn1Down_bySpare_P2,Bn1Down_bySpare_P3 and the values and then displayed all these values sorted by Bn1_SparesFill in ascending order.

Q1: How can I retrieve data from text file such that the same line item i.e. LRU1 properties Bn1_Failure, Bn1_SparesFill,Bn1_SparesWait, Bn1_DownBySpareP1, Bn1_DownBySpareP2 and Bn1_DownBySpareP3 can be stored in a array of structure and then be sorted based on the criteria when the criterias are unfixed and the sorting criteria is unfixed too.

The criterias are unfixed i.e. If the person chooses Bn1_LRUWait, another set of criterias associated with the selection in retrieved, this criteria may cause the values belonging to LRUWait
to be sorted in ascending order.

Can anyone please help? Thanks!
 
Mind if I ask why you are storing the data in a text file? Given the nature of the data (assuming I am understanding your explanation sufficiently) it seems that it is better suited for storage in a database. It would be much easier to do what you want to do here if it is stored that way.
 
I'll say start with using the Sorted property on a combo/list box which you can keep hidden if the data as sorted is not in the format you wish to display. Use ItemData property to keep track of indexes to arrays. You can read the sorted list box, format data from the arrays using the ItemData property from the sorted list and populate Sorted=False combo boxes etc. Beats messing with MDAC compatibility problems for a relatively small amount of data. Compare Code (Text)
Generate Sort in VB or VBScript
 
This is because the data that was given to me was presented in text file format so I have no choice but to read data from text file.

I am actually trying to manipulate the data in the text files to show the statistics about the contents i.e. 10 highest/lowest, averages, etc.

Assuming the all the items in the first column (e.g. Bn1_SparesFill, Bn1_SparesWait, Bn1Down_bySpare_P1,Bn1Down_bySpare_P2,Bn1Down_bySpare_P3, Bn1_TechFill,Bn1_TechWait,Bn1_Bn1Down_byTechI_P1,Bn1Down_byTechP2,Bn1_Down_byTechP3,Bn1_TechRprLRUFill,Bn1_TechRprLRUWait,Bn1UnRpr_byTech_P1,Bn1UnRpr_byTech_P2,Bn1UnRpr_byTech_P3, etc ) are added into a combo box

Upon choosing the criteria such as Bn1Down_bySpare_P3, it will find the top n(e.g. 5) highest number of Bn1Down_bySpareP3 and also at the same time show the corresponding records for Bn1_Failures, Bn1_SparesFill, Bn1_SparesWait, Bn1Down_bySpare_P1,Bn1Down_bySpare_P2,Bn1Down_bySpare_P3

Group 1
Criteria Chosen in Combo Box: Bn1Down_bySpare_P3
=>Retrieve n(e.g. 5) highest records sort by Bn1Down_bySpareP3
=>Any of the items selected
LRU Type Failures Spares Fill Spares Wait Bn1Down_bySpare_P1 Bn1Down_bySpare_P2 Bn1Down_bySpareP3
LRU_6 0.06 100% 11.8 0.02 0.03 0.099
LRU_3 0.04 100% 11.9 0.03 0.04 0.088
LRU_2 0.03 100% 11.2 0.04 0.05 0.032
LRU_1 0.07 98% 10.8 0.06 0.21 0.010
LRU_7 00.9 78% 12.6 0.07 0.31 0.009

Group 2
Criteria Chosen in Combo Box: Bn1_TechFill
=>Retrieve n(e.g. 5) lowest records sort by Bn1_TechFill
LRU Type Failures Tech Fill Tech Wait Bn1Down_byTechI_P1 Bn1Down_byTechI_P2 Bn1Down_byTechI_P3
LRU_9 0.06 38% 11.8 0.02 0.03 0.099
LRU_4 0.04 50% 11.9 0.03 0.04 0.088
LRU_1 0.03 70% 11.2 0.04 0.05 0.032
LRU_2 0.07 89% 10.8 0.06 0.21 0.010
LRU_7 00.9 100% 12.6 0.07 0.31 0.009

Group 3
Criteria Chosen in Combo Box: Bn1_TechRprLRUWait
=>Retrieve n(e.g. 5) highest records sort by Bn1_TechRprLRUWait
LRU Type Failures TechRprLRUFill TechRprLRUWait UnRpr_byTech_P1 UnRpr_byTech_P2 UnRpr_byTech_P3
LRU_6 0.06 100% 444.6 0.02 0.03 0.099
LRU_3 0.04 100% 291.8 0.03 0.04 0.088
LRU_2 0.03 100% 212.6 0.04 0.05 0.032
LRU_1 0.07 98% 104.7 0.06 0.21 0.010
LRU_7 00.9 78% 88.7 0.07 0.31 0.009

Qns:
1) How can I be able to create a structure or array to populate the relevant data accordingly by retrieving from the sql statement when the structure is not even fixed itself i.e. I cannot hardcode the elements as I do not know the number of elements beforehand whereby the elements in the structure can be anything like those listed in Group1, Group2 and Group3

Group1 elements
Fixed elements
1)LRU Type
2)Failures
3)Spares Fill
4)Spares Wait
Unfixed elements (this is because different files may have different number of profiles i.e. minimum number of profiles is 1 but maximum number of profiles can go up to 50)
5)Bn1Down_bySpare_P1
6)Bn1Down_bySpare_P2
7)Bn1Down_bySpareP3

Group2 elements
Fixed elements
1)LRU Type
2)Failures
3)Tech Fill
4)Tech Wait
Unfixed elements (this is because different files may have different number of profiles i.e. minimum number of profiles is 1 but maximum number of profiles can go up to 50)
5)Bn1Down_byTechI_P1
6)Bn1Down_byTechI_P2
7)Bn1Down_byTechI_P3

Group3 elements
Fixed elements
1)LRU Type
2)Failures
3)TechRprLRUFill
4)TechRprLRUWait
Unfixed elements (this is because different files may have different number of profiles i.e. minimum number of profiles is 1 but maximum number of profiles can go up to 50)
4)Bn1DownUnRpr_byTech_P1
5)Bn1DownUnRpr_byTech_P2
6)Bn1Down UnRpr_byTech_P3

How Is it possible to create an array of structure of unfixed elements????

Eg. Values(0).LRUType="LRU_1"
Values(0).Failures ="0.06"
Values(0).SparesFill= "100%"
Values(0).SparesWait="11.8"
Values(0).Bn1Down_bySpare_P1="0.02"
Values(0).Bn1Down_bySpare_P2="0.03"
Values(0).Bn1Down_bySpare_P3="0.099"

Can anyone please help??? I really have run out of ideas and knowledge on how I can do this in Visual Basic. Thanks a million!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top