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

Re: [Clip] Read CSV (was CVS)  rows and create html pages

Expand Messages
  • Alan C.
    On Fri, 22 Oct 2004 22:21:28 -0000, antiquewatch wrote: [ . . ] ... Ok. I just took your html with the variables in it and I made it into a Notetab template
    Message 1 of 16 , Oct 22, 2004
    • 0 Attachment
      On Fri, 22 Oct 2004 22:21:28 -0000, antiquewatch wrote:
      [ . . ]
      > [a bunch of html code]<a href="http://www.mysite.com/^%ItemID%pics.htm
      > " TARGET="_blank"><img
      > src="http://www.mysite.com/graphics/^%ItemID%x150.jpg" width="112"
      > height="150" border="0" alt=""><br><font size="-1" color=999999>Click
      > for more pictures</font></a></td>
      >
      >  <td><center><b><h4>^%ItemTitle% </h4></b></center>
      > [ . . ]

      > I left in the instances where the variables are lcoated in the html,
      > so you could see how they are interspersed throughout.  I guess this
      > could have easily been done with a search and replace, but this is at
      > least working.

      Ok. I just took your html with the variables in it and I made it into a Notetab template file.

      field2htm.tpl

      I named it that ^ (next line up). And I put a header on it like Notetab's native HTML template and I saved it in Notetab's templates folder.

      file > template > edit

      but CAREFUL not to edit, just look instead (at the native templates, as examples).

      But for some reason, it wouldn't interpolate (wouldn't dump the variable contents into the outputted template html/text) and I don't know why it wouldn't ouput the variable content.

      But, perhaps some of all of this gives you some ideas. At least the enclosed clip puts a comma delimited line into array then visual ouputs, via looping, each delimited item then calls open the template in the hope of bringing up the html and dumping the variable contents as well (but the variable contents do not dump out--seems like it should, perhaps I had something off a bit).

      Next, a couple sample data line to run clip on:

      myitemid1,myitemtitle1,myitemprice1,myitemshipcost1
      myitemid2,myitemtitle2,myitemprice2,myitemshipcost2

      Next is clip:

      ^!SetListDelimiter ,
      ^!SetArray %Fields%=^$GetLine$
      ^!Set %Idx%=0
      :info
      ^!Inc %Idx%
      ^!Info ^%Fields^%Idx%%
      ^!If ^%Idx% => 4 next else info

      ^!Set %ItemID%=^%Fields1%; %ItemTitle%=^%Fields2%
      ^!Set %ItemPrice%=^%Fields3%; %ShippingPrice%=^%Fields4%
      ^!Open ^$GetShort(^$GetTemplatePath$field2htm.tpl)$
      ;^!RenameDoc ^%ItemID%.htm
      ;----<end_of_clip-------

      --
      Alan.
    • hsavage
      ... antiquewatch, I m not sure of everything you re trying to do, when you talk about includes you leave me, I m not that familiar with the jargon. How many
      Message 2 of 16 , Oct 25, 2004
      • 0 Attachment
        antiquewatch wrote:
        >
        > Thanks for the reply, Alan.
        >
        > First excuse me. I did mean a CSV file. I do like your solution, and
        > I will remember it for the right application.
        >
        > What I have already done is set values to variables in a prompt, and
        > then the info is put in as the page is created. What I would like to
        > do is eliminate the prompt and have the data in a file--CSV ;) I
        > don't even know how to "pick up" the data so I can do something with
        > it. I can leave the file unopened or open it which ever is easier.
        >
        > ^!MENU File/New
        > ^!Set %ItemID%=^?{Enter Item ID}; %ItemTitle%=^?{Enter Item Title};
        > %ItemPrice%=^?{Enter Price--no dollar sign}
        >
        > ^!RenameDoc ^%ItemID%.htm
        > ^!AppendToFile "NewIncludes" <!--# include virtual = "^%ItemID%.htm"
        > -->^%NL%
        >
        > I left in the instances where the variables are lcoated in the html,
        > so you could see how they are interspersed throughout. I guess this
        > could have easily been done with a search and replace, but this is at
        > least working.
        >
        > Again, any help appreciated.
        >
        >
        >> antiquewatch wrote:
        >> [ . . ]
        >>
        >>> If I have the cvs file open, what command[s] will read each line into
        >>> an array? [If an array command is not appropriate, what is?]
        >>

        antiquewatch,

        I'm not sure of everything you're trying to do, when you talk about
        'includes' you leave me, I'm not that familiar with the jargon.

        How many fields per row/record do you plan to have in your CSV file?
        What will each field be?

        What, exactly, is the the html code snippet, and will it be the same,
        other than the variables every time?

        I've built a test CSV file with 9 fields per row using examples from you
        emails and I used the html code snippet from email also.

        With these I constructed a clip that will convert the CSV to an array, a
        line at a time, and create a small discrete html file after reading a
        CSV record/row into variables.

        The number of files created depends on your discretion or the number of
        rows in the CSV file.

        Currently the test database is only 8 records, it can create 8
        individual html files using each of the records/rows in the CSV file.
        I'm using the ^%ItemID% field #1 of each record as the name of the html
        file.

        It takes 1 click of the mouse to create each file although, it could be
        automated to require no user assistance other than starting the clip.

        If interested let me know.

        A TEMPLATE would be ideal but I've tried several methods to get it to
        work completely with little success.

        I maintain a site that depends almost entirely on TPL files and it works
        great but, I do remember, it took a very long time to get all the right
        combinations to allow the templates to work correctly and to substitute
        the data for the variables.

        hrs
      • antiquewatch
        ... solution, and ... line into ... you ... array, a ... works ... An include in html simply is a command that references to another file that is to be
        Message 3 of 16 , Oct 25, 2004
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, hsavage <hsavage@p...> wrote:
          > antiquewatch wrote:
          > >
          > > Thanks for the reply, Alan.
          > >
          > > First excuse me. I did mean a CSV file. I do like your
          solution, and
          > > I will remember it for the right application.
          > >
          > > What I have already done is set values to variables in a prompt, and
          > > then the info is put in as the page is created. What I would like to
          > > do is eliminate the prompt and have the data in a file--CSV ;) I
          > > don't even know how to "pick up" the data so I can do something with
          > > it. I can leave the file unopened or open it which ever is easier.
          > >
          > > ^!MENU File/New
          > > ^!Set %ItemID%=^?{Enter Item ID}; %ItemTitle%=^?{Enter Item Title};
          > > %ItemPrice%=^?{Enter Price--no dollar sign}
          > >
          > > ^!RenameDoc ^%ItemID%.htm
          > > ^!AppendToFile "NewIncludes" <!--# include virtual = "^%ItemID%.htm"
          > > -->^%NL%
          > >
          > > I left in the instances where the variables are lcoated in the html,
          > > so you could see how they are interspersed throughout. I guess this
          > > could have easily been done with a search and replace, but this is at
          > > least working.
          > >
          > > Again, any help appreciated.
          > >
          > >
          > >> antiquewatch wrote:
          > >> [ . . ]
          > >>
          > >>> If I have the cvs file open, what command[s] will read each
          line into
          > >>> an array? [If an array command is not appropriate, what is?]
          > >>
          >
          > antiquewatch,
          >
          > I'm not sure of everything you're trying to do, when you talk about
          > 'includes' you leave me, I'm not that familiar with the jargon.
          >
          > How many fields per row/record do you plan to have in your CSV file?
          > What will each field be?
          >
          > What, exactly, is the the html code snippet, and will it be the same,
          > other than the variables every time?
          >
          > I've built a test CSV file with 9 fields per row using examples from
          you
          > emails and I used the html code snippet from email also.
          >
          > With these I constructed a clip that will convert the CSV to an
          array, a
          > line at a time, and create a small discrete html file after reading a
          > CSV record/row into variables.
          >
          > The number of files created depends on your discretion or the number of
          > rows in the CSV file.
          >
          > Currently the test database is only 8 records, it can create 8
          > individual html files using each of the records/rows in the CSV file.
          > I'm using the ^%ItemID% field #1 of each record as the name of the html
          > file.
          >
          > It takes 1 click of the mouse to create each file although, it could be
          > automated to require no user assistance other than starting the clip.
          >
          > If interested let me know.
          >
          > A TEMPLATE would be ideal but I've tried several methods to get it to
          > work completely with little success.
          >
          > I maintain a site that depends almost entirely on TPL files and it
          works
          > great but, I do remember, it took a very long time to get all the right
          > combinations to allow the templates to work correctly and to substitute
          > the data for the variables.
          >
          > hrs


          > I'm not sure of everything you're trying to do, when you talk about
          > 'includes' you leave me, I'm not that familiar with the jargon.

          An "include" in html simply is a command that references to another
          file that is to be included/inserted at that location. The html
          command is:
          <!--# include virtual = "date_insert.html" -->

          > How many fields per row/record do you plan to have in your CSV file?
          > What will each field be?

          I now have the following in a prompt that contains all of the variables:
          %ItemID%, %ItemTitle%; %ItemPrice%; %ShippingPrice%; %EchoNumber%;
          %ItemOPT1%; %ItemOpt2%; %ItemOpt3%; %ItemOpt4%

          > What, exactly, is the the html code snippet, and will it be the same,
          > other than the variables every time?

          The code is too long to show here, but it is the same code in the same
          locations for each page that is created--with the substitution of
          variables. I could email you the clip that I have created with
          prompts for input if it would help--at least it works.

          What I have working prompts for the variables and creates the page
          named %ItemID%.html which is exactly what I want. I haven't been able
          to solve the template substitution of varable values, so I don't use a
          template.

          IT sounds like you have done exactly what I need. I have been unable
          to read the cvs file into an array. It would be fine to create each
          new page within the loop, then loop back, read the next line in the
          file, create another page, etc. There really would be no need to have
          the extra keystroke.

          I am actually trying to do this for a friend. She has been using a
          template file and manually inserting the relevant information for each
          product, and doing a "save as". What I have done so far will help her
          and save her a lot time by eliminating the tedious work. [She also
          was creating a unique picture page for each item, and I wrote a php
          program to count the number of pictures that start with "ItemID", and
          then create an html file and put in the appropriate link to those
          pictures when she passes the ItemID to the program.]

          Anyway, I wold love to see what you have done. I have 4 or 5 failed
          attempts I wouldn't mind deleting. Having just started to see the
          power and benefit of these clips, I still have a way to go.
        • Alan C.
          On Mon, 25 Oct 2004 22:53:15 -0000, antiquewatch wrote: [ . . ] ... Nuther, or a way for use of template (that works). Yes, next works (if desire template).
          Message 4 of 16 , Oct 26, 2004
          • 0 Attachment
            On Mon, 25 Oct 2004 22:53:15 -0000, antiquewatch wrote:
            [ . . ]
            > [ . . ]  I haven't been able
            > to solve the template substitution of varable values, so I don't use a
            > template.

            'Nuther, or a way for use of template (that works). Yes, next works (if desire template).

            is to call a clip that is a dedicated as a template. (sorry for mixup), I'd forgotten that it seems the .tpl sort/kind seem to end up reserved for certain things but in this case didn't yet work.

            But for a template that works, Just use the

            ^!Clip

            command to call up essentially your template with vars kept there in such child clip.

            I ran Pete's clip on the next sample. worked great. (If you experiment with these or similar additions), I'd start off with not too many csv lines as each csv line becomes a document (as the clip is written now).

            myitemid1,myitemtitle1,myitemprice1,myitemshipcost1
            myitemid2,myitemtitle2,myitemprice2,myitemshipcost2
            myitemid3,myitemtitle3,myitemprice3,myitemshipcost3

            All clips shared been great. I thought Pete's clip great, tested it. just tinkering, next, I added (#1) one more csv sourcefile choice and (#2) I added a clip call command to it and (#3) a child (as a template) clip.

            H="main_csv_clip" . . .
            [ snip most of clip except for #1 and #2 ]

            (addition) #1:

            ; Get CSV file contents to an array
            ^!SetListDelimiter ^p
            ; ^!SetArray %Records%=^$GetFileText(c:\temp\test.csv)$
            ; 1 more csv source choice of current doc
            ^!SetArray %Records%=^$GetFileText(^**)$
            ^!If ^%Records0% = 0 END

            (addition) #2:

            ; Whatever you want here
            ; receptor doc and then call sub (template) clip
            ^!Menu file/new
            ^!Clip field2htm
            ;--end of the short addittion

            ^!Set %Variables%=Variables: (Record ^%RecordIndex%)^p
            ^!Append %Variables%=^$StrFill("-";100)$^p^p
            ;----end of additions to main clip-------------


            (addition) #3:
            Child or sub routine "template" clip is next

            H="_field2htm"
            <a href="http://www.mysite.com/^%ItemID%pics.htm
            " TARGET="_blank"><img
            src="http://www.mysite.com/graphics/^%ItemID%x150.jpg" width="112"
            height="150" border="0" alt=""><br><font size="-1" color=999999>Click
            for more pictures</font></a></td>

            ^!InsertHtml <td><center><b><h4>^%ItemTitle% </h4></b></center>

            a bunch more html
                     
            <td><b><h4><small>^%ItemOpt1%<br>^%ItemOpt2%<br>^%ItemOpt3%<br>^%ItemOpt4%</small></h4></b></td>
                            <td> </td>
                            <td><small>Item<br>^%ItemID%</small></td>
                            <td> </td>
                              <td align="center"><small>  <!-- <FONT COLOR="#FF0000">SOLD</FONT>
            -->  $^%ItemPrice%<br></small>
                            <small>(shipping: $^%ShippingPrice%) </small></td>
            more html
            ; ----end of template/child clip--------------

            --
            Alan.
          • Don Passenger
            did you try what I posted the other day? it worked fine as near as I could tell it generated the html page, appended to the includes file, etc. it didn t need
            Message 5 of 16 , Oct 26, 2004
            • 0 Attachment
              did you try what I posted the other day?
              it worked fine as near as I could tell
              it generated the html page, appended to the includes file, etc.

              it didn't need a template at all, you can just output the html right
              from the clip
            • David Elliott
              I have a large clip that maintains a 2000 link website organized across a number of pages. If you are interested, I don t mind zipping the clip and a couple
              Message 6 of 16 , Nov 16, 2004
              • 0 Attachment
                I have a large clip that maintains a 2000 link website organized
                across a number of pages. If you are interested, I don't mind zipping
                the clip and a couple of the CSV files for you to see how it can be
                implemented. There are 33 functions in the clip including
                automatically FTPing the HTML files after they have been created (I'll
                have to blank out that part, I'm afraid :-/ )

                I can't do a lot of explanation of what is going on in the file, but
                the CSV reading functions are fairly well documented including using
                variable indexed arays (^%array^%i%% sorts of things)

                DE
              • Don Passenger
                I might find that of interest. I use the csv 2 tables clip that I think Joe Barta wrote. It is old (using html instead of xhtml) and uses comma as the sole
                Message 7 of 16 , Nov 16, 2004
                • 0 Attachment
                  I might find that of interest. I use the csv 2 tables clip that I think
                  Joe Barta wrote. It is old (using html instead of xhtml) and uses comma
                  as the sole delimiter. I have thought about updating it. Also it acts
                  on the whole file, and not just a highlighted part. So I am interested
                  in seeming some thoughts on that.

                  It sounds like you might do well to investigate the power of databases,
                  includes and some of the other handy things available out there.

                  David Elliott wrote:
                  >
                  > I have a large clip that maintains a 2000 link website organized
                  > across a number of pages. If you are interested, I don't mind zipping
                  > the clip and a couple of the CSV files for you to see how it can be
                  > implemented. There are 33 functions in the clip including
                  > automatically FTPing the HTML files after they have been created (I'll
                  > have to blank out that part, I'm afraid :-/ )
                  >
                  > I can't do a lot of explanation of what is going on in the file, but
                  > the CSV reading functions are fairly well documented including using
                  > variable indexed arays (^%array^%i%% sorts of things)
                  >
                  > DE
                • David Elliott
                  I have done an extract of the support files and a modified clip I use for the linkfarm. If you wish to experiment with this, d/l and extract the file
                  Message 8 of 16 , Nov 16, 2004
                  • 0 Attachment
                    I have done an extract of the support files and a modified clip I use
                    for the linkfarm.

                    If you wish to experiment with this, d/l and extract the file
                    referenced below to a directory of your choice.
                    Find the two *.clb files in the created directory and put them in your
                    Notetab clip library
                    Run the PW.clb - it will prompt for the working directory where the
                    files were extracted.
                    Run the "Generate Home Page" then the "Generate Pages Automatically"
                    clip and chose Acute Care
                    and/or Addictions (the only two CSV files I included) It should
                    generate the two HTML pages but would fail when it hits the FTP step
                    if you say "yes".

                    The clip has a bit of everything, persistent variables, writing to
                    registry, CSV reading, sorting, errorchecking, use of indexed arrays,
                    calling external programs, creating picklists from external files . . .

                    It is all documented to some extent (we should all document more, eh?)
                    and I am prepared to answer a limited # of questions.

                    Pick up the file at:
                    http://f3.grp.yahoofs.com/v1/QFyaQWKLaqjr8aya-ks5TDJaqj8nG5VrcNHkmF82T-6wecVFwKdgwSezLOyruC0S0Su-RYaCUYMgKZvG5dgYn0fFLLgvpZYEZLSgjZKzbZNypeZ3/Policy%20Watch.zip

                    DE
                  • Don Passenger
                    bad link as near as I can figure ...
                    Message 9 of 16 , Nov 16, 2004
                    • 0 Attachment
                      bad link as near as I can figure ...

                      David Elliott wrote:
                      >
                      > I have done an extract of the support files and a modified clip I use
                      > for the linkfarm.
                      >
                    • hsavage
                      ... Don, Try this link. http://groups.yahoo.com/group/ntb-clips/files/Policy%20Watch.zip ºvº hrs hsavage@pobox.com
                      Message 10 of 16 , Nov 16, 2004
                      • 0 Attachment
                        Don Passenger wrote:
                        > bad link as near as I can figure ...
                        >
                        > David Elliott wrote:
                        >
                        >> I have done an extract of the support files and a modified clip I use
                        >> for the linkfarm.

                        Don,

                        Try this link.

                        http://groups.yahoo.com/group/ntb-clips/files/Policy%20Watch.zip

                        ºvº
                        hrs <04-11-16> hsavage@...
                      Your message has been successfully submitted and would be delivered to recipients shortly.