Script or Macro to convert an array of glosses to a list

Script or Macro to convert an array of glosses to a list

24
Basic UserBasic User
24

    Apr 29, 2012#1

    Hello,
    I have a database with the following structure:
    Headword in a foreign language followed by frequency (delimited with comma) and eventually followed by a list of glosses in English, each gloss delimited with a comma. A small sample is given below
    कुर्यवंशी,4,kuryanshi,kuryavanashi,kuryawanshi,kurywanshi
    कुर्रे,2,kurray,kurre
    कुलदिपकर,2,kuladipakar,kuladipkar
    कुलदीपसिंग,4,kuldeepsing,kuldeepsingh,kuldipsing,kuldipsingh
    कुलभूषण,2,kulbhooshan,kulbhushan
    कुवरसिंग,4,kuvarsing,kuvarsingh,kuwarsing,kuwarsingh
    कुशवाह,3,kushavan,kushawah,kushawaha
    कुशवाहा,2,kushavah,kushavaha
    कुशाबराव,2,kushabrao,kushabrav
    कुशेश्वर,2,kusheshvar,kusheshwar
    I need a script or a macro to convert these into the following format. The first item from the example is given as a converted item.
    कुर्यवंशी,4,
    कुर्यवंशी=kuryanshi
    कुर्यवंशी=kuryavanashi
    कुर्यवंशी=kuryawanshi
    कुर्यवंशी=kurywanshi
    The macro I have written is too slow and takes a large amount of time. Basically the macro selects the headword. Pastes it onto a next line, chooses the first gloss (deletes it), pastes it onto the headword on line 2, preceded by an equal to sign and carries on till all the glosses on a line are exhausted. The process is repeated till all the headwords are exhausted.
    The macro takes ages , since the glosses for a single headword are considerable and also because there are a large number of headwords.
    Any way of speeding the process up would be gratefully acknowledged.
    Many thanks

    6,681583
    Grand MasterGrand Master
    6,681583

      Apr 29, 2012#2

      Okay, a macro doing this transformation faster.

      InsertMode
      ColumnModeOff
      HexOff
      UltraEditReOn
      Top
      Loop 0
      Find RegExp "%^(*^),^(?+^),^(*^)$"
      Replace All "^1,^2^p^1=^3"
      IfNotFound
      ExitLoop
      EndIf
      EndLoop
      Find RegExp "%^(*,*^)$"
      Replace All "^1,"

      The regular expression in the loop executed until no replace done anymore, combines the string from start of line to first comma, with the string after last comma to end of line in a line below while removing the string after last comma. By doing this replace in a loop all English words are removed from the line with the number. The last regular expression replace all appends the comma after the counting number after making the transformation to get exactly the result you want.

      24
      Basic UserBasic User
      24

        Apr 30, 2012#3

        Dear Mofi,
        The macro works like a charm. It replaced 40,000 rows in around 48 seconds approximately. Many thanks for saving precious time.