WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

List Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

CSV to TAB List Conversion.wbt

Keywords: 	 CSV to TAB list conversion

This UDF is now outdated, as the WIL Language now has built-in functions, ItemExtractCSV and ItemCountCSV, that make this UDF pretty much obsolete. However for people with older versions of WinBatch, this information is being kept here.


#DefineFunction CSV2TAB(csv)
   newline=""
   inquote=0
   csvlen=strlen(csv)
   for xx=1 to csvlen
      char=strsub(csv,xx,1)
      if char=='"'
          if inquote==0 then inquote=1
          else inquote=0
          continue
      else
          if char==',' && inquote==0 then char=@tab
      endif
      newline=strcat(newline,char)
   next
   return(newline)
#EndFunction


csvline='aaa,bbb,"ddd, fff",123,"dfdfdf"'

tabline=CSV2TAB(csvline)

Message(csvline,tabline)




Article ID:   W14989
File Created: 2003:03:12:14:56:26
Last Updated: 2003:03:12:14:56:26