Jump to content
Sign in to follow this  
minjin

I need help with this script

Recommended Posts

minjin

Hi everyone,

i need to read a file, sort this list and then output the whole as a plain html table. I have this so far:

#include <array.au3>
#include <file.au3>

$sEingabe = @ScriptDir & "\test.csv"
$sAusgabe = @ScriptDir & "\table.html"

LogSortieren($sEingabe, $sAusgabe)
Exit

Func LogSortieren($sEingabe, $sAusgabe)
    Dim $aDaten
    ;Einlesen
    _FileReadToArray($sEingabe, $aDaten)
    ;Array sortieren
    _ArraySort($aDaten, 0, 1)
    ;_ArrayDisplay($aDaten)
    ;schreiben
    _FileWriteFromArray($sAusgabe, $aDaten, 1)
EndFunc   ;==>LogSortieren

The only thing is missing is the output into a html table. Help will be really appreciated, thanks.

Share this post


Link to post
Share on other sites
ripdad

; base example

FileWriteLine($sAusgabe, '<html><body><table border="1" width="600" height="100" align="center"><tr><td align="left">')

; Insert your data here

FileWriteLine($sAusgabe, '</td></tr></table></body></html>')


"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites
smartee

Ich hoffe, das hilft

#include <Array.au3>
#include <File.au3>

$out = @ScriptDir & "\test.html"
Dim $lines
_FileReadToArray(@ScriptDir & "\test.csv", $lines)
For $i = 1 To $lines[0]
    If $i = 1 Then
        FileWriteLine($out, '<table border="1"><tr>')
        $cols = StringSplit($lines[$i], ",")
        For $j = 1 To $cols[0]
            FileWriteLine($out, "<th>" & $cols[$j] & "</th>")
        Next
        FileWriteLine($out, '</tr>')
    Else
        $cols = StringSplit($lines[$i], ",")
        FileWriteLine($out, '<tr>')
        For $j = 1 To $cols[0]
            FileWriteLine($out, "<td>" & $cols[$j] & "</td>")
        Next
    EndIf
    FileWriteLine($out, '</tr>')
Next
FileWriteLine($out, '</table>')
FileClose($out)

Share this post


Link to post
Share on other sites
minjin

Thanks yeah this did the work but its still an unclean table with @ signs.

Share this post


Link to post
Share on other sites
ripdad

A forum search of CSV in the title, returned 96 results.

Heres a few to try...

CSV-Editor by funkey

_CSV_ToHTML by taietel


"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.