www.webdeveloper.com
Results 1 to 9 of 9

Thread: A script that will download csv file and show it on a web page

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    5

    A script that will download csv file and show it on a web page

    Hello everyone.

    I am new here. Just curious if you can help me with this....

    Currently I am working on a automation project and one of the tasks I need to do is to show a data log on a web page.
    Basically, a PLC (device that is used in industry automation) will save a data log .csv file on a web server. I need to
    access that file and show it on a web page in a table. So far I have searched across the web for solution but a lot of
    those solutions use jquery or PHP which I can't use (PHP because server can't use it, and jquery because it's too large, PLC has a limited memory space). Can you help me?

    Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    funny, i wrote a great tool last month to do that: danml.com/bind/
    it doesn't need jQuery or phpm and has a lot of examples and documentation online.

    let me know if you need a hand getting it to work for your specific needs/server/site...

  3. #3
    Join Date
    Apr 2013
    Posts
    5
    Quote Originally Posted by rnd me View Post
    funny, i wrote a great tool last month to do that: danml.com/bind/
    it doesn't need jQuery or phpm and has a lot of examples and documentation online.

    let me know if you need a hand getting it to work for your specific needs/server/site...
    Hey, thanks for your help. Your tool seems to be exactly what I need, however, I have a hard time making it work...

    This is what I wrote in my HTML file:

    Code:
    <OBJECT id="tdcLog" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
    	<PARAM NAME="DataURL" VALUE="/log.csv">								  
    	<PARAM NAME="UseHeader" VALUE="True">
    	<param name="RowDelim" value="\n" />
    	<param name="FieldDelim" value="," />
    	<PARAM NAME="TextQualifier" VALUE=",">
    </OBJECT>
    						
    			<TABLE datasrc=#tdcLog border=1>
    <THEAD><TR>
       <TD>Datum</TD><TD>Ime</TD><TD>Prezime</TD><TD>Email</TD>
       </TR></THEAD>
    <TBODY>
    <TR>
       <TD><DIV datafld="datum"></DIV></TD>
       <TD><DIV datafld="ime"></DIV></TD>
       <TD><DIV datafld="prezime"></DIV></TD>
       <TD><DIV datafld="email"></DIV></TD>
    </TR>
    </TBODY>
    </TABLE>
    and this is log.csv

    Code:
    datum	ime	prezime	email	
    datum1, ime1, prezime1, email
    datum2, ime2, prezime2, email
    datum1, ime1, prezime1, email
    datum2, ime2, prezime2, email
    I know there is something that I am doing wrong, but I can't find out. Thanks for you help and your tool.

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    it looks like your csv file has no commas in in the header row, which would prevent it from working.

    also, this should not be the same as the delimeter:

    <PARAM NAME="TextQualifier" VALUE=",">

    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    you can just delete the param to use the default (quote ).
    Last edited by rnd me; 04-14-2013 at 11:24 PM.

  5. #5
    Join Date
    Apr 2013
    Posts
    5
    I copied this:

    Code:
    	<OBJECT id="tdcComposers" CLASSID="clsid:lxw5wyjv-46wm-6lxr-bl9h-yp9avjwcdizk">
    	<PARAM NAME="DataURL" VALUE="https://docs.google.com/spreadsheet/pub?key=0Aptc98y5K95RdGdOaGdubFk2YWh5ZEkxVGNpeFF4clE&output=csv">								  
    	<PARAM NAME="UseHeader" VALUE="True">
    	<PARAM NAME="TextQualifier" VALUE="'">
    </OBJECT>
    
    
    			
    			
    			<TABLE datasrc=#tdcComposers>
    <THEAD><TR>
       <TD>Long Term</TD><TD>Right Now</TD><TD>Date</TD><TD>Comments</TD>
       </TR></THEAD>
    <TBODY>
    <TR>
       <TD><DIV datafld="Long Term"></DIV></TD>
       <TD><DIV datafld="Right Now"></DIV></TD>
       <TD><DIV datafld="Timestamp"></DIV></TD>
       <TD><DIV datafld="What do you think?"></DIV></TD>
    </TR>
    </TBODY>
    </TABLE>
    from your example and the only thing that is displayed on my web page is

    Code:
    Long Term	Right Now	Date	Comments
    So I think something is not right?? I did put <script type='text/javascript' src='http://danml.com/bind/'></script> in head of my HTML file? Do you know why is it not working?

    Thanks

  6. #6
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    i just tested this ok:

    make sure the <script> tag is at the bottom, after the <table> and <object>
    Code:
    
    <html>
    <head></head><body>
    
    <OBJECT id="tdcComposers" CLASSID="clsid:lxw5wyjv-46wm-6lxr-bl9h-yp9avjwcdizk">
    	<PARAM NAME="DataURL" VALUE="https://docs.google.com/spreadsheet/pub?key=0Aptc98y5K95RdGdOaGdubFk2YWh5ZEkxVGNpeFF4clE&output=csv">								  
    	<PARAM NAME="UseHeader" VALUE="True">
    	<param name="Sort" value="-Timestamp" />
    	<PARAM NAME="TextQualifier" VALUE="'">
    </OBJECT>
    
    
    			
    			
    			<TABLE datasrc=#tdcComposers>
    <THEAD><TR>
       <TD>Long Term</TD><TD>Right Now</TD><TD>Date</TD><TD>Comments</TD>
       </TR></THEAD>
    <TBODY>
    <TR>
       <TD><DIV datafld="Long Term"></DIV></TD>
       <TD><DIV datafld="Right Now"></DIV></TD>
       <TD><DIV datafld="Timestamp"></DIV></TD>
       <TD><DIV datafld="What do you think?"></DIV></TD>
    </TR>
    </TBODY>
    </TABLE>
    
    
    <script src="http://danml.com/bind"></script>
    </body></html>
    Last edited by rnd me; 04-14-2013 at 11:34 PM.

  7. #7
    Join Date
    Apr 2013
    Posts
    5
    Oh yeah, the only thing that gets printed to my page is table header, and the next row is generated but it is empty.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles