Loading ...
Sorry, an error occurred while loading the content.

Re: [Clip] txt to xml - li'l mistake

Expand Messages
  • loro
    I m sorry. I shouldn t be allowed to use an email program. The first line should of course be h= fruitXML NOT fruitXML Sigh. Lotta
    Message 1 of 8 , Apr 13, 2008
    • 0 Attachment
      I'm sorry. I shouldn't be allowed to use an email program.

      The first line should of course be

      h="fruitXML"

      NOT

      fruitXML


      Sigh.
      Lotta
    • dracorat
      I have a similar clip if you d like to see it. It s no better than the one posted I think, but it s good for the purposes of analysis if anyone would like to
      Message 2 of 8 , Apr 14, 2008
      • 0 Attachment
        I have a similar clip if you'd like to see it. It's no better than the
        one posted I think, but it's good for the purposes of analysis if
        anyone would like to read over them for education. Let me know and
        I'll post it.

        The biggest changes I can see are that mine will show a progress
        percent (because I tend to do large files) and I don't store all the
        results then write them, I write them as I go. It's probably a bit
        slower that way, but I consume much less memory in processing.

        --Keith

        --- In ntb-clips@yahoogroups.com, loro <loro-spam01-@...> wrote:
        >
        > I'll give it a go. Each line is basically an array, so let's use
        > that. The below clip assumes the fruit lists are all there is in the
        > document and that there are no blank lines at the bottom either. It
        > jumps to the start of the doc and chews line by line until there are
        > no more, then it writes out the XML in a new document. I didn't test
        > it much, so FWIW...
        >
        > Oh, at least one long line will wrap in email so you have to unwrap
        > it. I marked the spots with comments.
        >
        > [...]
        >
        > Lotta
        >
      • Michael Bramley
        Thanks Keith and Lotta. Yes, Keith, anything that sheds a bit more light will be great. Michael
        Message 3 of 8 , Apr 14, 2008
        • 0 Attachment
          Thanks Keith and Lotta. Yes, Keith, anything that sheds a bit more
          light will be great. Michael

          On 14/04/2008, dracorat <dracorat@...> wrote:
          > I have a similar clip if you'd like to see it. It's no better than the
          > one posted I think, but it's good for the purposes of analysis if
          > anyone would like to read over them for education. Let me know and
          > I'll post it.
          >
          > The biggest changes I can see are that mine will show a progress
          > percent (because I tend to do large files) and I don't store all the
          > results then write them, I write them as I go. It's probably a bit
          > slower that way, but I consume much less memory in processing.
          >
          > --Keith
          >
          > --- In ntb-clips@yahoogroups.com, loro <loro-spam01-@...> wrote:
          > >
          > > I'll give it a go. Each line is basically an array, so let's use
          > > that. The below clip assumes the fruit lists are all there is in the
          > > document and that there are no blank lines at the bottom either. It
          > > jumps to the start of the doc and chews line by line until there are
          > > no more, then it writes out the XML in a new document. I didn't test
          > > it much, so FWIW...
          > >
          > > Oh, at least one long line will wrap in email so you have to unwrap
          > > it. I marked the spots with comments.
          > >
          > > [...]
          > >
          > > Lotta
          > >
          >
          >
          >
        • dracorat
          Here you go - watch for line breaks and at the top of the file, there are two lines you should chage to whatever file you d like the clip to save to I do that
          Message 4 of 8 , Apr 14, 2008
          • 0 Attachment
            Here you go - watch for line breaks and at the top of the file, there
            are two lines you should chage to whatever file you'd like the clip
            to save to

            I do that for batch automation.

            --Keith
            -----------------------------
            ^!SetScreenUpdate Off
            ^!SET %DocIndex%=^$GetDocIndex$
            ^!SET %FName%="C:\output.xml"
            ^!SET %Progress%=0
            ^!SET %LastProgress%=-1
            ^!SET %FileCheck%=^$GetFiles("c:\";output.XML)$
            ^!SetWordWrap OFF
            ^!If "^%FileCheck%" > "" NEXT ELSE CreateFile
            ^!Open ^%FName% /J=-1
            ^!SetWordWrap OFF
            ^!Goto BeginWork
            :CreateFile
            ^!TOOLBAR New Document
            ^!SetWordWrap OFF
            ^!Save AS ^%FName%

            :BeginWork
            ^!SetDocIndex ^%DocIndex%
            ^!Jump DOC_START
            ^!Set %TotalLines%=^$GetLineCount$
            ^!Set %CurrentLine%=0

            :WorkLoop
            ^!Select LINE
            ^!SET %Progress%="^$Calc((^%CurrentLine%/^%TotalLines%)*100;1)$"
            ^!IF ^%Progress% = ^%LastProgress% NoUpdate
            ^!SET %LastProgress%=^%Progress%
            ^!StatusShow "^%Progress%%"
            :NoUpdate
            ^!Find "([^\,]+)\,([^\,]+)\,([^\,]+)\,([^\,]+)" HRS
            ^!SetArray %Data%=^$GetReSubStrings$
            ^!IF ^%Data0% < 4 BADROW
            ^!SET %Data1%=^$StrReplace("&";"&";^%Data1%;False;False)$
            ^!SET %Data2%=^$StrReplace("&";"&";^%Data2%;False;False)$
            ^!SET %Data3%=^$StrReplace("&";"&";^%Data3%;False;False)$
            ^!SET %Data4%=^$StrReplace("&";"&";^%Data4%;False;False)$
            ^!Open ^%FName% /J=-1
            ^!InsertText
            "<fruit><fruitname>^%Data1%</fruitname><fruititemcode>^%Data2%</fruititemcode><fruitbarcode1>^%Data3%</fruitbarcode1><fruitbarcode2>^%Data4</fruitbarcod2></fruit>^P"
            :^!Save AS ^%FName%
            ^!Goto PostProcessing

            :BadRow

            :PostProcessing
            ^!SetDocIndex ^%DocIndex%
            ^!Set %CurrentLine%="^$Calc(^%CurrentLine%+1)$"
            ^!If ^%CurrentLine%=^%TotalLines% FinishOut
            ^!Select 0
            ^!Jump +1
            ^!Goto WorkLoop

            :FinishOut
            ^!Select 0
            ^!Jump DOC_END
            ^!Open ^%FName% /J=-1
            -----------------------------

            --- In ntb-clips@yahoogroups.com, "Michael Bramley"
            <michaelbramley@...> wrote:
            >
            > Thanks Keith and Lotta. Yes, Keith, anything that sheds a bit more
            > light will be great. Michael
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.