mardi 25 mars 2014

Import CSV File data into DataGridView between two rows


Vote count:

0




I'm completely lost on this. Here's what's going on. I have a CSV file with a bunch of data, however I only need a certain piece of this data. There is a bunch of stuff online about selecting it by range (ex: F15:L20), but I don't know that data because it changes - depending on the number of entries.


Here's an example CSV file



NAME RYAN
DATE 3/25/2014

ID SECID FID LAST NAME FIRST NAME NOTES
1 3 1003 Doe John -
2 4 1004 Doe John -
3 5 1005 Doe John -
4 2 1002 Doe John -
5 1 1001 Doe John -
FINAL
ID SECID FID LAST NAME FIRST NAME NOTES
**1 4 1004 Doe John** -
**2 5 1005 Doe John** -
**3 2 1002 Doe John** -
**4 3 1003 Doe John** -
**5 1 1001 Doe John** -
OTHER RECORDS


What I need imported is the ID, SECID, FID, LAST NAME, & FIRST NAME of everything that is FINAL (the range is selected by asterisks). Since we don't know how many records there are (5 in this case) I need to be able to do a search by the value FINAL and OTHER RECORDS then I can skip a row after FINAL and then select everything through column E (First Name) up until the point where the value OTHER RECORDS value is found.


Theoretically, I can just search the CSV file for FINAL, get its location and then do everything off of that. In this case it would be like this. FINAL's location is A10. If we subtract the row value by 5, we will know how many records there are. Now we add skip row 11 and then select everything in A12 through E17 and we will get the values.


I'm sorry if this is very confusing. I just can't find a good way to explain it. I believe I can get this to work by just searching the file for FINAL and getting it's location and then doing math to figure out how many records and then use a range to collect the data. However, I posted everything else in case someone had an easier way to do things.



asked 49 secs ago






Aucun commentaire:

Enregistrer un commentaire