![]() |
import huge text file line-by-line?
I'm trying to automate importing an enormous text file. The full file has
over 1000 fields (don't ask... it's just what I have to deal with). I want to bring in around 150 or so of the fields. I recorded a macro using the text import wizard. There were too many line continuations, so I tried to condense the code into fewer lines. Because of the number of fields, however, there's still way too much code and not enough allowable line continuations. I've read suggestions for importing the text line by line and truncating just what I want, but i'm not sure how to do it. The text file is delimited with a ~ character. The first field has names formatted as "last, first" (no quotes, but there is a comma). Because the first field is a name, the length of that field will vary by person, as will the length of some of the other fields. I don't know how to write the code that will snip out just those fields i want while taking into account the varying length of some of the fields. Any help would be appreciated. rachael |
import huge text file line-by-line?
did you try the split function. You can use something like fields = Split(line_number, "~") This will put the fields in the array fields, and then you can impor only those numbers which you want by referring to them as field(0) field(4), field(21), etc... - Manges -- mangesh_yada ----------------------------------------------------------------------- mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047 View this thread: http://www.excelforum.com/showthread.php?threadid=27584 |
import huge text file line-by-line?
Haven't tried it, but i will. Thanks for the tip.
rachael "mangesh_yadav" wrote: did you try the split function. You can use something like fields = Split(line_number, "~") This will put the fields in the array fields, and then you can import only those numbers which you want by referring to them as field(0), field(4), field(21), etc... - Mangesh -- mangesh_yadav ------------------------------------------------------------------------ mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470 View this thread: http://www.excelforum.com/showthread...hreadid=275849 |
All times are GMT +1. The time now is 09:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com