How to handle $null values? - 03/01/06 08:47 AM
I have a fair size text file (265 lines at present), which was generated by saving a spreadsheet in a comma delimited text file format (hope I got the phrasing correct, or at least understandable).
Ideally, each line would have 10 items in it, however, some of them don't and using $numtok(<line>,44) is returning either 8, 9 or 10 items
Here's an example of the format of the lines in the text file. First one has items missing (generating a count of 8, when using $numtok). Second one has everything in place. I think that the easiest way to handle this would be to put in something for dummy data where it's currently returning $null (and therefore not counting the number of tokens correctly)
Any suggestions as to a way that I can insert dummy data between double commas, without having to go through each line manually?
There are up to three possible locations where the $null value might be getting returned...for lack of a better way of describing them, in reference to the second item in the quote, the possibilities would be at tokens numbered 5, 6 &/or 9...the rest of the locations have guaranteed entries. I know that if $numtok returns 10, then none of the three locations needs dummy data, and if it returns 7 then all three locations need the dummy data, but if it returns 8 then only 2 of the three locations need the dummy data, and if it returns 9, then one of the three needs the dummy data.
I don't know how to determine (aside from visually inspecting the line), which location(s) needs the dummy data.
Ideally, each line would have 10 items in it, however, some of them don't and using $numtok(<line>,44) is returning either 8, 9 or 10 items
Here's an example of the format of the lines in the text file. First one has items missing (generating a count of 8, when using $numtok). Second one has everything in place. I think that the easiest way to handle this would be to put in something for dummy data where it's currently returning $null (and therefore not counting the number of tokens correctly)
Quote:
rte,address,street,ST,N,,name,account,,MTWHFS
rte,address,street,RD,S,apt,name,account,mm/dd/yyyy,MTWHFS
rte,address,street,RD,S,apt,name,account,mm/dd/yyyy,MTWHFS
There are up to three possible locations where the $null value might be getting returned...for lack of a better way of describing them, in reference to the second item in the quote, the possibilities would be at tokens numbered 5, 6 &/or 9...the rest of the locations have guaranteed entries. I know that if $numtok returns 10, then none of the three locations needs dummy data, and if it returns 7 then all three locations need the dummy data, but if it returns 8 then only 2 of the three locations need the dummy data, and if it returns 9, then one of the three needs the dummy data.
I don't know how to determine (aside from visually inspecting the line), which location(s) needs the dummy data.