Re: Re: Parsevar question
Dimitris Keletsekis <[email protected]>
| Newsgroups | gmane.comp.windows.gui4cli |
|---|---|
| Message-ID | <[email protected]> |
Yes... parsevar will "eat-up" a series of delimiters in one go. It does "while delimiters, advance.." It was done to help parse jumbled text, but I see now that was a dumb idea.. For now you can do what Chris suggested. You could also add some code to handle an empty first field: if $text[0][1] = ',' text = $text[1] endif Otherwise you could maybe use repvar to convert all commas to tabs and load it into a listview. I haven't tried... You may have to save it as a .glv file first and load it again. Dimitris On Mon, Jun 13, 2011 at 3:35 AM, chris.kevany <[email protected]>wrote: > > > Hi Frans, > > You could keep the database "as is" and at the time > you read-in a number of records in a variable, use repVar > to change all occasions of ,, into ,"", > > > Text = '2352,Tuesday,2,,Comm,,WhC,C3.68' > repvar text ',,' ',"",' > ParseVar Text "," > say $$Parse.total > > This is not full-proof however if you also expect empty > records at the start or end of the string like; > > Text = ',2352,Tuesday,2,,Comm,,WhC,C3.68,' > > Perhaps someone else knows a better solution. > > Chris > > > --- In [email protected], "Marianne" <marianne976@...> wrote: > > > > All users > > > > I need some help with Parsevar if possible please. > > > > If I open the following in Excel from a csv file > > > > "2352","Tuesday","2","","Comm","","WhC","C3.68" > > > > and save it again as comma delimited (csv) from Excel it is saved as" > > > > 2352,Tuesday,2,,Comm,,WhitingC,C3.68 (unfortunately!!) > > > > Now let: > > > > Text = '"2352","Tuesday","2","","Comm","","WhC","C3.68"' > > > > ParseVar Text "," gives $$Parse.total = 8 > > > > Next let: > > > > Text = '2352,Tuesday,2,,Comm,,WhC,C3.68' > > > > then > > > > Parsevar text "," gives $$Parse.total = 6 (two fields ignored) > > > > So When a field is "empty" as in the second example it is not "picked" up > by Parsevar. > > > > If I do have the following it is working but then I must loop through a > file of thousands of records looking for two consecutive comas (,,) and > replace it with ," ", with a space between "". > > > > teks = '2352,Tuesday,2," ",Comm," ",WhC,C3.68' > > > > > > Is there an easy way of overcoming this? > > > > > > Any help is appreciated. > > > > Kind regrads. > > > > Frans > > > > >