Jump to content

I need help with this script


Recommended Posts

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.

Link to comment
Share on other sites

; 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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...